Sub Form_Error(DataErr ......

D

dave h

Hi

I have a form that opens many other forms based upon button clicks. Rather
than put error handling in each button on-click sub, I thought I could use
Form_Error to trap the error if Access could not find the form. It is not
important which specific form did not open - just need to trap the error,
give a message and move on. The missing form run-time error does not seem
to fire this Form_Error event. I've tried to trap a test "division-by-zero"
error in this manner and have also not been successful.

Is it possible to trap these types of run-time errors in Form_Error? If so,
what must I do?

Thanks, Dave H.
 
M

Mark Phillipson

Hi,

The Form Error event only fires when the form causes a runtime data error.
This includes validation and datatype errors as well as most locking errors.

To trap a normal runtime error you will still need to enter On Error Goto
<NameOfErrorHandler> in each procudure.

If you create a function that opens a form, with the form name supplied as a
string then you will be able to have the error handler in the function i.e.

Public Function OpenSomeForm(strFormName As String)

On Error GoTo HandleErr
DoCmd.OpenForm strFormName, acNormal

ExitHere:
Exit Function

HandleErr:
Select Case Err.Number
Case Else
MsgBox "An Error has occured please inform IT developer support " &
Err.Number & ": " & Err.Description, vbCritical, "Form_Form1.OpenSomeForm"
Resume ExitHere
End Select
'Debug Only
Resume
End Function


--
HTH

Mark Phillipson

Free Add-Ins at; http://mphillipson.users.btopenworld.com/
 
D

dave h

Hi Mark,

Thanks for the clarification. I didn't realize that only certain types of
errors would bubble up to the Form_Error.

Thanks again, Dave H.
 

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

Similar Threads

Continue after Form_Error 4
Error info not available 7
On Form Error: MsgBox 3
subform does not trap errro 2
Unbound form + duplicate values error message 12
Error 3314 2
Form Errors 2
Form_beforeUpdate question 5

Top