Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi Jacob
thanks for reply am struggling a bit with this (probably beyond my abilities !) isthere another way without date picker or something I can insert into existing code fo rthe text box on the form ? -- thanks Roy "Jacob Skaria" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
permanent conversion of 1904 date format to 1900 date format | Excel Worksheet Functions | |||
How do I change dates input as 20080426 to date format in Excel? | Excel Discussion (Misc queries) | |||
input date format "ddmmyyyy" | Excel Worksheet Functions | |||
need help with a conditional format in regards to "date" input | Excel Discussion (Misc queries) | |||
input a date or update it based on date in another cell | New Users to Excel |