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

Error Handling in Access Runtime

Status
Not open for further replies.

number2

Technical User
Oct 25, 2001
284
US
In Access Runtime, error result in program termination unless they are handled by code. I need to handle a printing error that occurs if the user cancels printing because the printer preselcted by the run time application is not installed.

How can I trap this error so the program does not terminate?
 
OOPS - Here is the code I am trying:

Private Sub Label282_Click()
Dim strCriteria As String

On Error GoTo HandleErr
Call EnterProc("Form_QME/AME Information.Label282_Click")

strCriteria = "[QME/AME Information]![lastname]=[Forms]![QME/AME Information]![lastname]"
DoCmd.OpenReport "patient Label", acNormal, , strCriteria

ExitHere:
Call ExitProc("Form_QME/AME Information.Label282_Click")
Exit Sub

' Error handling block added by VBA Code Commenter and Error Handler Add-In. DO NOT EDIT this block of code.
' Automatic error handler last updated at Thursday, December 13, 2001 10:55:21 PM
HandleErr:
Select Case Err.Number
Case Else
MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, "Form_QME/AME Information.Label282_Click"
End Select
' End Error handling block.
End Sub
 
Number 2,

You need to add a line at the top of your code to tell the routine to use the errorhandler you have added, using the developers toolkit addin, when an error is encountered.

You can edit the error handling block and add in a new Case statement to specifically handle this particular error.

Use this (see second line):

Private Sub Label282_Click()
On Error GoTo HandleErr

Dim strCriteria As String

On Error GoTo HandleErr
Call EnterProc("Form_QME/AME Information.Label282_Click")

strCriteria = "[QME/AME Information]![lastname]=[Forms]![QME/AME Information]![lastname]"
DoCmd.OpenReport "patient Label", acNormal, , strCriteria

ExitHere:
Call ExitProc("Form_QME/AME Information.Label282_Click")
Exit Sub

' Error handling block added by VBA Code Commenter and Error Handler Add-In. DO NOT EDIT this block of code.
' Automatic error handler last updated at Thursday, December 13, 2001 10:55:21 PM
HandleErr:
Select Case Err.Number
Case Else
MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, "Form_QME/AME Information.Label282_Click"
End Select
' End Error handling block.
End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top