Results 1 to 4 of 4
  1. #1
    dhav79 is offline Novice
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Posts
    3

    Form Field Validation

    Hey guys,



    I have an access form with 8 fields that require a date range validation.

    ex.

    PlanningA Start Date
    PlanningB End Date

    PlanningC Start Date
    PlanningD End Date

    PlanningE Start Date
    PlanningF End Date

    etc..


    I need the Start Date to be <= to the End date, if the user does not enter it correctly, I need a msgbox to display "PlanningA Start date should be less then PlanningB End Date". I've found some vb codes, but haven't gotten them to work.

    Please help.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I'd use the before update event of the form:

    http://www.baldyweb.com/BeforeUpdate.htm

    You would simply test one date against the other.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    dhav79 is offline Novice
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Posts
    3
    Thanks for the quick reply, but i dont think that solves my issue. I need something that does the following:

    if
    (PlanningA Start Date > PlanningB End Date)
    then
    msgbox="Start does has to be less then the End date ex. 02-02-2009 Start - 01-01-2010 End."


    So therefore, if the the date range is correct, move onto the next field.

    Remember we are validating between two fields at a time, ex. PlanningA Start Date to PlanningB End Date.

    Love to hear more suggestions.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Like I said:

    Quote Originally Posted by pbaldy View Post
    You would simply test one date against the other.
    You've basically typed it all out yourself. The code would look like:

    Code:
    If Me.StartDateField > Me.EndDateField Then
      msgbox "Start does has to be less then the End date ex. 02-02-2009 Start  - 01-01-2010 End."
      'Do whatever you want here
    End If
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Comparing form field with the field from database
    By np1111 in forum Programming
    Replies: 1
    Last Post: 03-22-2010, 10:01 AM
  2. Linked Table Field Validation
    By yuriyl in forum Access
    Replies: 4
    Last Post: 04-20-2009, 01:31 PM
  3. Referencing table data in field validation rule
    By toad848 in forum Database Design
    Replies: 3
    Last Post: 03-19-2009, 07:03 AM
  4. Validation rule for a text field
    By wasim_sono in forum Forms
    Replies: 4
    Last Post: 03-14-2006, 11:39 PM
  5. Field Level Date validation
    By fadone in forum Forms
    Replies: 1
    Last Post: 12-09-2005, 10:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums