Is this exceptable?

B

Bob

The Me.Dirty Script:
Private Sub Command17_Click()


On Error GoTo Err_Command336_Click

Dim stDocName As String
If Me.Dirty Then Me.Dirty = False
stDocName = "rptSpellingPrint"
DoCmd.OpenReport stDocName, acPreview

Exit_Command336_Click:
Exit Sub

Err_Command336_Click:
MsgBox Err.Description
Resume Exit_Command336_Click

End Sub

Thanks Bob
 
S

strive4peace

control names, error handling
---

Hi Bob,

looks like it will work

I would suggest, however, before you write code for controls that you
give them a non-ambiguous name

Command17 must be the Name property of your command button control. A
better Name would be something like cmdSpellingPrintReport

~~~

also, on error handling:

put this at the top of your program, right after the procedure
declaration (skip a line first for better readability)

'~~~~~~~~~~~~~~~~~~~~~~
'set up Error Handler
On Error GoTo Proc_Err

'~~~~~~~~~~~~~~~~~~~~~~
... then your statements
'~~~~~~~~~~~~~~~~~~~~~~

put this at the end of the program

'~~~~~~~~~~~~~~~~~~~~~~
Proc_Exit:
On Error Resume Next
'release object variables if any
Exit Function 'or Exit Sub

Proc_Err:
MsgBox Err.Description, , _
"ERROR " & Err.Number _
& " ProcedureName"

'press F8 to step through code and debug
'remove next line after debugged
Stop: Resume
Resume Proc_Exit

'~~~~~~~~~~~~~~~~~~~~~~

where
ProcedureName is the name of your procedure so you can identify what
code the problem is in when you see the error

While I am developing, I like to make the error handler go to the line
that caused the problem so I can see where it is. Stop will stop the
code and Resume goes back to the offending line. When code Stops, press
F8 to execute one statement at a time.

The line labels do not matter (Proc_Exit:, Proc_Err:), I like to use the
same ones all the time -- they only have to be unique within a procedure.


Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 

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

Top