freightguy
Registered User.
- Local time
- Today, 08:54
- Joined
- Mar 1, 2016
- Messages
- 36
Hi all - I am having a difficult time locating my problem. I have an error handling code in the "On Exit" event of a form's button. This event runs through a recordset then compiles and sends an email. On the same command button I have an "On Click" event that controls the data input for about a dozen fields (data validation).
When the user populates the form's fields the On Click event will run it's course and find anything blank, pop a message and set focus to blank field. No problem. Problem arises when user leaves the recordset blank. The message pops up (error 3021) however I can't figure out how to set focus to the specific field in the recordset or even set focus to any field on the form.
The application keeps shutting down. I want the program to go back to a field on the form so user has a chance of completing his form.
If there is anything else required please let me know.
thank you
When the user populates the form's fields the On Click event will run it's course and find anything blank, pop a message and set focus to blank field. No problem. Problem arises when user leaves the recordset blank. The message pops up (error 3021) however I can't figure out how to set focus to the specific field in the recordset or even set focus to any field on the form.
The application keeps shutting down. I want the program to go back to a field on the form so user has a chance of completing his form.
Code:
ErrorHandler:
Dim iAnswer As Integer
Select Case Err.Number
Case 0
Resume
Case 20
MsgBox "error code 20"
Exit Sub
Case 3021 ' recordset is null (no record found)
MsgBox "There are no Shipping Details to report. Your request is incomplete. Please continue to add shipping details or click on the UNDO button to clear all and start over."
' ????? - needs to set focus somewhere on the form (example I have a field called "ProjectNumber"
Case 3265
MsgBox "error code 3265"
Exit Sub
Case Else
MsgBox "Please contact XXX in XXXX at rayxxx@xxxxltd.com with the error code information. Unexpected error occured. " & Err.Number & " " & Err.Description
Exit Sub
End Select
If there is anything else required please let me know.
thank you