View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default Date input format

Why dont you use the calendar control or a DT Picker... OR if you dont have
these controls you can build one...


You could build one. In a fresh UserForm place a textbox (TextBox1) and try
pasting the below code ...Use up/down arrows to adjust the time


Private Sub UserForm_Activate()
Me.TextBox1 = Format(Now, "dd/mm/yyyy")
End Sub
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
'Date and Time Picker Use down/up arrow to change date/time.
Dim intPos As Integer, strType As String
If KeyCode = 38 Or KeyCode = 40 Then
intPos = Me.TextBox1.SelStart
strType = Application.Lookup(intPos, Array(0, 3, 6), Array("d", "m", "yyyy"))
Me.TextBox1 = Format(DateAdd(strType, (39 - KeyCode), TextBox1), "dd/mm/yyyy")
KeyCode = 0
Me.TextBox1.SelStart = intPos
End If
End Sub


--
Jacob (MVP - Excel)


"Roy Gudgeon" wrote:

Hi Guys

I have a date entry form.
One box requires a date.

I have several users using the form, each types the date in a different way.

I would like a consistant dd/mm/yyyy format. I know that access allows an
input mask to be set, can this be done in a text box on a data entry form ?

thanks
Roy


--
thanks
Roy