Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2008
    Posts
    3

    Unanswered: Date entry on form

    How would I prevent a date being entered into a form from defaulting to the current year.

    For example, the user enters 6/13 in the date field, when enter ot tab is hit the firld is then defaulted to 6/13/2008. How would I make the 6/13 entry fail instead of defaulting to the current year.

    thanks!

  2. #2
    Join Date
    Feb 2004
    Posts
    214

    ...

    Change the format in the table to mm/dd/yyy
    Also I usually like setting an input mask on the field in the form or in the table.
    You know, I'm sick of following my dreams, man. I'm just going to ask where they're going and hook up with 'em later

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I suppose you could test the number of characters input by the user....
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Code:
    Private Sub YourDateField_BeforeUpdate(Cancel As Integer)
     If Not IsNull(YourDateField) Then
      If Len(YourDateField.Text) - Len(Replace(YourDateField, "/", "")) < 2 Then
        Cancel = True
        MsgBox "You must enter an entire date!"
      End If
     End If
    End Sub
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •