• Validating Rule (2002 SP3)

    • This topic has 2 replies, 2 voices, and was last updated 18 years ago.
    Author
    Topic
    #442421

    I am looking to set the validation rule so dates can only be in a certain range. I can get the validation rule to work if it simply greater than or less then but not between the two dates. There will be a few different validation rule sets for the same field. This is a small snippet from the On Got Focus event. Any help is greatly appriceated.

    Dim strVRule As String
    Dim strVText As String
    Dim dteDate1 As Date
    Dim dteDate2 As Date
    Dim dteDate3 as Date

    dteDate1 = DateAdd(“d”, -28, Now())
    dteDate2 = DateAdd(“d”, -1, Now())
    dteDate3 = DateAdd(

    Viewing 0 reply threads
    Author
    Replies
    • #1064959

      Since dteDate1 and dteDate2 are used between the quotes, the validation rule will contain the names of the variables as literal text, not the values of the variables. Moreover, date values should be enclosed in # characters.

      The validation rule should look like this:

      strVRule = “Between #” & Format(dteDate1, “mm/dd/yyyy”) & “# And #” & Format(dteDate2, “mm/dd/yyyy”) & “#”

      Please note that only one validation rule can be active at the same time for a control. If you need complex conditions, it’s better to check them in the Before Update event of the control.

      • #1064966

        After posting I was wondering about the dteDate1 and dteDate2 between the quotes. Thanks for you help, working as attended now.

    Viewing 0 reply threads
    Reply To: Validating Rule (2002 SP3)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: