Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2005
    Location
    Utah
    Posts
    136

    Unanswered: VBA If Statement

    Probably a dumb question but I am still trying to learn VBA. I have an If statement:

    Private Sub End_Date_BeforeUpdate(Cancel As Integer)
    If Me.End_Date => Me.Start_Date Then

    ????????????????

    Else
    MsgBox "Check your date range. The End Date must be equal to or after the Start Date."
    End If
    End Sub

    I don't know what code to write after Then Statement for the record to go ahead and update.

    Thanks!
    Last edited by Zenaida; 01-03-06 at 19:19.

  2. #2
    Join Date
    Sep 2005
    Location
    Utah
    Posts
    136
    I changed the code:

    Private Sub End_Date_BeforeUpdate(Cancel As Integer)
    If Me.End_Date >= Me.Start_Date Then

    Else
    MsgBox "Check your date range. The End Date must be equal to or after the Start Date."
    End If
    End Sub

    Seems to work. Please let me know if you see problems with it. Also, how can I keep the record from updating if the end date is less than the start date? Do I need to use another event other than the Before Update?

  3. #3
    Join Date
    Sep 2005
    Location
    Utah
    Posts
    136
    Ok I added Me.Undo and it seems to work - but it undoes all changes. How can I make it so it only affects the EndDate?
    Last edited by Zenaida; 01-03-06 at 19:27.

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Try Cancel = True instead of the Undo line.
    Paul

  5. #5
    Join Date
    Sep 2005
    Location
    Utah
    Posts
    136
    Thank you ever so much pbaldy!

Posting Permissions

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