Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Handlers on a form

Status
Not open for further replies.

NC1977

Programmer
Nov 26, 2007
22
CA
Hello,

Here is my script to handle a few errors on my form before the user can print:


If De > A Then
Msgbox "Your FROM date cannot be bigger than your TO date"
ElseIf IsNull(Mandat) Then
Msgbox "Please enter the file number!"
ElseIf IsNull(De) Then
Msgbox "Your FROM date cannot be blank!"
ElseIf IsNull(A) Then
Msgbox "Your TO date cannot be blank"
ElseIf IsNull(Daterequis) Then
Msgbox "You must enter a due date!"
Else
DoCmd.OpenReport "Requete Lawson AP", acViewPreview
End If

I would also like to add that the user cannot put a due date that is smaller then today... I've tried using "Today()" but it does not work.

Any suggestions or any idea on how to simplify my code??

Thank you
 
The function to return the current date is Date() rather than Today(). Alternatively Now() (which returns the current date and time) may be more suitable.

Ed Metcalfe.

Please do not feed the trolls.....
 
Replace this:
ElseIf IsNull(Daterequis) Then
with this:
ElseIf Nz(Daterequis, 0) < Date Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I would check if DE and A or Null before doing the smaller than comparison.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top