Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2004
    Posts
    11

    Unanswered: Validating Dates in a text box

    I'm trying to validate and end date field on a form. I have the following if statement on the field after the End Date:

    Private Sub End_Time_BeforeUpdate(Cancel As Integer)
    If (Me.EndDate < Me.StartDate) Then
    MsgBox "End Date should be greater than or equal to Start Date"
    Cancel = True
    End If
    End Sub

    The message box will pop up if my End Date is less than the Start Date field, but it also pops up if the End Date is equal to the Start Date. Shouldn't the "<" keep that from happening? Please correct me if I'm wrong.
    Last edited by Decemuirs; 03-15-04 at 15:40.

  2. #2
    Join Date
    Feb 2004
    Posts
    142

    Re: Validating Dates in a text box

    Originally posted by Decemuirs
    I'm trying to validate and end date field on a form. I have the following if statement on the field after the End Date:

    Private Sub End_Time_BeforeUpdate(Cancel As Integer)
    If (Me.EndDate <= Me.StartDate) Then
    MsgBox "End Date should be greater than or equal to Start Date"
    Cancel = True
    End If
    End Sub

    The message box will pop up if my End Date is less than the Start Date field, but it also pops up if the End Date is equal to the Start Date. Shouldn't the "<=" keep that from happening? Please correct me if I'm wrong.
    remove the equal sign, the code is working as designed.
    KC

Posting Permissions

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