Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Mar 2005
    Location
    Anderson, Indiana, USA
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Validating Rule (2002 SP3)

    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(

  2. #2
    2 Star Lounger
    Join Date
    Mar 2005
    Location
    Anderson, Indiana, USA
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Validating Rule (2002 SP3)

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

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Validating Rule (2002 SP3)

    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.

Posting Permissions

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