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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Handling

Status
Not open for further replies.

bjarvis

Technical User
Jan 15, 2001
38
US
I've got a form with a date text box. I want to write my own error handler for the date if the user trys to go to the next record without entering the date. Here's the code that I tried but I don't know which event procedure to put it in.

If Err.Number=3314 Then
msgbox("You must enter the date before proceeding.")
End If
 
bjarvis

This might get you going on the right direction.

Public Sub ErrorHandling_Err()
On Error GoTo ErrorHandling_Err
---put what ever other code here-------
ErrorHandling_Exit
Exit Sub

ErrorHandling_Err:
Select Case Err.Number
Case 3314 ' no date entered
Resume
Case Else
Msg: what ever you want
Resume ErrorHandling_Exit
End Select
Exit Sub

msgbox("You must enter the date before proceeding.")
 
Another thing that you might look at instead of using an error handling routing is to:
1> default the field to either date() or now()
2> prior to exiting the record drop a piece of code in such as If Me!DateFieldName = "" then
msgbox "A date is required to save this record"
Me!DateFieldName.Setfocus
End If

This will lock them into having to fill in the field.
Just another couple of options.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top