Hi Dave,
add an error handler to your code
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'--------- put this line at top of procedure:
On Error GoTo procedurename_Error
'... other statements
'--------- add these lines to bottom of procedure
'if everything executed normally, exit the procedure
'Exit sub -- use if the procedure is a Sub
Exit Function
procedurename_Error:
MsgBox Err.Description, , "ERROR " & Err.Number & "
procedurename"
'press F8 to step through lines of code
'to see where problem is
'comment next 2 lines out after debugged
Stop
Resume
resume procedurename_Error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if, during execution, an error flag is raised, execution
will go to the error handler, which is denoted with a line label
procedurename_Error:
a line label is a word before a colon
-- you can change the name before the colon -- but you
cannot have the same line label twice in the same module sheet
once the execution goes to the error handler, a message box
is issued describing the problem, and then the code is
STOPped with
Stop
Press the F8 key ( which is the shortcut key to single-step
through code) once to go to the next line
Resume
tells the process to go back to the line that caused the
problem.
press F8 again to go to the actual offending line
(from menu -->
Debug, Step Into: each line (F8)
Debug, Step Over: each line in current procedure (Shift-F8)
(treat called functions as one line)
You can then fix the problem, save your code, and then
resume the code (right-click on the line where you want to
resume and choose "Set Next Statement" from the shortcut menu)
then, either F5 to RUN (from the menu bar: Run, Run)
or F8 to continue stepping through code
OR
to stop the procedure
(from the menu bar: Run, Reset)
if, at any point during execution, you want to STOP the
code, press CTRL-BREAK -- you may have to hold the Control
key and repeatedly press the Pause/Break key until Access
pays attention to the keyboard. In your code, you can put
in a line that MAKES it pay attention to the keyboard:
DoEvents
If I have a loop, I often put DoEvents into the loop while I
am developing. Sometimes DoEvents is necessary to make
changes "stick" -- like if you are writing to a form from
code that is not behind the form, or changing data with an
SQL statement.
Have an awesome day
Warm Regards,
Crystal
MVP Microsoft Access
strive4peace2006 at yahoo.com