Date Entry Validation

  • Thread starter junior00 via AccessMonster.com
  • Start date
J

junior00 via AccessMonster.com

Hello.
I have a form/sub form into which I enter times (start and end) for a given
process.
User selects the process in the main form, and the sub form contains the
fields into which the start time and end time are entered.

There can be several entries per process. I have been able to enter in
validation so that end time is greater than start time - no problem. What I
would like to do is further add validation - not only is end time greater
than start time, but when user proceeds with a new entry for a process the
subsequent start time must be after the previous end time.

Any help would be much appreciated.

Thanks,
GZ
 
K

Klatuu

You can use the Form AfterUpdate event of the record to populate a module
level date variable with the value of the end time. Then in your Form
BeforeUpdate event or Start Time control BeforeUpdate, you can compare the
current start time with the the saved value in the module level variable.

The only trick is there will nothing to compare for the very first record,
so you have to allow for that in your coding.
This would be an example in the control's Before Update event:

If Not IsNull(dtmLastEndTime) Then
If dtmLastEndTime > MetxtStartTime Then
MsgBox "Start Time Must be After " & dtmLastEndTime
Cancel = True
End If
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top