Problems to Debug code

D

DaveAlfa

Hi!

i have a database, ran the Database Spliiter & also compiled my VB code.
Though the program works fine, i would like to debug my program. so i ran my
program sales.mdb (not the sales.mde) & set some break points in my code.

the problem is that the program does not stop on my break points, though i'm
100% sure that it's passing from my code. this happened after i had compiled
my program, even though i'm running sales.mdb

should i do something else to debug my program?

thanks!

Dave
 
C

Crystal

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
 
T

Tom Wickerath

Hi Dave,

If you removed the check for "Use Access Special Keys", found in Tools >
Startup..., then code will not break at a set break point.


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

:

Hi!

i have a database, ran the Database Spliiter & also compiled my VB code.
Though the program works fine, i would like to debug my program. so i ran my
program sales.mdb (not the sales.mde) & set some break points in my code.

the problem is that the program does not stop on my break points, though i'm
100% sure that it's passing from my code. this happened after i had compiled
my program, even though i'm running sales.mdb

should i do something else to debug my program?

thanks!

Dave
 
T

Tom Wickerath

Crystal,
-- you can change the name before the colon -- but you
cannot have the same line label twice in the same module sheet

This statement is incorrect. You most certainly can use the same line label
many times in the same module sheet. In fact, I use ProcError: and ExitProc:
labels in all procedures in the same module sheet.


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
C

Crystal

Thanks, Tom

I did not realize the rules had changed... you used to not
be able to do that so I just never do... that is truly nice
to know!

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
 
C

Crystal

Thank you, Tom

Because of the people I usually develop for, I like to keep
everything available... just don't want (some of) them
getting scared when they go into the code (not that it
happens often ;) )

I bookmarked your website -- it looks like you have some
great stuff posted!

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
 
D

DaveAlfa

Thanks for all the replies as it sovled my problem & got some useful info.

Actually I had removed the check for "Use Access Special Keys", found in
Tools.

regards,

DAve
 
C

Crystal

you're welcome, Dave ;)

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
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