input mask checking for date and time

  • Thread starter Thread starter louiethek
  • Start date Start date
L

louiethek

Guest
I looking for an input mask to require the user to input date and time. Can't seem to find one. Any help would be greatly appreciated.
 
Use a Date/Time field and they'll have no choice in the matter. Otherwise you're going to be limited to forcing them to use one format, or using IsDate() as a check before processing.

David R
 
I appreciate your response but I do not believe it is correct. The field is date/time. If you enter just a date, the time is defaulted to 12:00 AM. I did find a solution:
format mm/dd/yy hh:nn AM/PM
input mask - 00/00/00\ 00:00\ >LL;0;" "
 
Sorry, I misunderstood what you meant by "require them to enter date and time". Glad you got it working.

You could probably also do a validation check that made sure the time component wasn't 0.
Code:
Private Sub DateTimeField_BeforeUpdate(Cancel As Integer)
   Dim m As Integer
   If Int(Me.DateTimeField.Value) = Me.DateTimeField.Value Then
        m = MsgBox("Is the time for this entry truly 12:00 AM?",vbYesNo)
        If m = vbNo Then
            Me.Undo
            Cancel = True
        End If
    End If

End Sub
HTH,
David R
 
Last edited:

Users who are viewing this thread

Back
Top Bottom