Results 1 to 2 of 2
  1. #1
    sprtrmp is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Location
    Greenville, SC
    Posts
    102

    Validation rule for minimum amount of time between the values in 2 fields

    OK access wizards, here's one for you. I am sure this will be easy for someone out there:



    I have a form with 2 fields, "TimeStart," and "TimeEnd". That a user would use to input the time they arrived at work, and the time they left to go home. "TimeEnd" has to be at least 4 hours after "TimeStart". What would I need to use as a validation rule to make sure that the time entered in "TimeEnd" is at least 4 hours after "TimeStart"??

    If "TimeEnd" is fewer that 4 hours later than "TimeStart", some event needs to take place (either a message box or the control would change color, but I haven't figured that part out yet).

    But wait, there is more: it is entirely possible that "TimeStart" could be later than 9pm, and the validation rule needs to recognize the fact that 0100 is AFTER 2100... if that makes any kind of sense.

    Thanks in advance for the help.

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,460
    you really need start and end date fields as well, then you would have something like

    if datediff("n",dateend+timeend,datestart+timestart)< (4*60) then msgbox "checking out too soon"

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

Similar Threads

  1. Validation rule based on 2 fields
    By Slush in forum Access
    Replies: 9
    Last Post: 08-10-2016, 02:17 PM
  2. Replies: 11
    Last Post: 07-07-2016, 06:21 PM
  3. Cannot set validation rule on Date/Time type
    By intheflesh77 in forum Access
    Replies: 2
    Last Post: 10-12-2013, 08:57 AM
  4. Replies: 1
    Last Post: 05-29-2013, 04:01 PM
  5. Validation rule for time
    By jle0003 in forum Access
    Replies: 3
    Last Post: 05-22-2012, 02:45 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