Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2004
    Location
    United Kingdom
    Posts
    56

    Unanswered: Date cannot be after today

    Hello,

    I have a date field on a form and I don't want the user to be able to enter a date that's in the future, i.e. not after today. I have tried using the code below and want the field to be blanked out and a message box to appear telling them that they can't do that.

    Is it something like the code below plus:

    DateOfEvent.Undo
    MsgBox "You CANNOT enter a date which is AFTER today"

    Please help,

    Rusty


    Code:
    Private Sub DateOfEvent_AfterUpdate()

    If (Me.DateOfEvent > Date) Then

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by Rusty's Way
    Hello,

    I have a date field on a form and I don't want the user to be able to enter a date that's in the future, i.e. not after today. I have tried using the code below and want the field to be blanked out and a message box to appear telling them that they can't do that.

    Is it something like the code below plus:

    DateOfEvent.Undo
    MsgBox "You CANNOT enter a date which is AFTER today"

    Please help,

    Rusty


    Code:
    Private Sub DateOfEvent_AfterUpdate()

    If (Me.DateOfEvent > Date) Then
    Put it in your BeforeUpdate event ...

    If Cdate(DateOfEvent.Value) > Date then
    Msgbox "Warning! Warning! Dr. Smith ..."
    cancel=1
    exit sub
    endif
    Back to Access ... ADO is not the way to go for speed ...

  3. #3
    Join Date
    Apr 2004
    Location
    United Kingdom
    Posts
    56
    Thanks for your help.

    The code works but before (or after) the user clicks on OK, I need the field to be blanked out.

    Any ideas?

    Rusty

  4. #4
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by Rusty's Way
    Thanks for your help.

    The code works but before (or after) the user clicks on OK, I need the field to be blanked out.

    Any ideas?

    Rusty
    If you use the afterupdate event then you can reset the .Value to "" ...
    Back to Access ... ADO is not the way to go for speed ...

Posting Permissions

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