Debugging code

G

Guest

This is a really elementary question. In Access 2003, I can't seem to get the
debugger working.

I open the code editor
Click F8 or Debug, step into
I get a tone but nothing happens
Is there something not downloaded from the install disc?

I desperately need to step through some code.
Thanks
 
A

Allen Browne

Hi Sam.

Put the cursor in the first line of the procedure after any comments or Dim
statements, and press F9. This gives you a break point.

Then run the code. If it's a public procedure named MyFunc, you could do
that by opening the Immediate Window (Ctrl+G), and entering:
Call MyFunc
If it is a private sub in a form, you can fire it by clicking the button
whatever event will trigger it.

The code will then pause, and you can press F8 to step line-by-line (or F5
to complete the whole thing.)

Suggestions:
1. Choose Compile from the Debug menu before you start running the code.
This catches any compiler errors.

2. DON'T alter the code in break mode. There are some scenarios where this
will corrupt the database--the kind of corruption that requires a Decompile
to fix. You're safe if you End the code (Run menu), and then switch the form
to design view before editing its module.
 
G

Guest

Allen Browne said:
Hi Sam.

Put the cursor in the first line of the procedure after any comments or Dim
statements, and press F9. This gives you a break point.

Then run the code. If it's a public procedure named MyFunc, you could do
that by opening the Immediate Window (Ctrl+G), and entering:
Call MyFunc
If it is a private sub in a form, you can fire it by clicking the button
whatever event will trigger it.

The code will then pause, and you can press F8 to step line-by-line (or F5
to complete the whole thing.)

Suggestions:
1. Choose Compile from the Debug menu before you start running the code.
This catches any compiler errors.

2. DON'T alter the code in break mode. There are some scenarios where this
will corrupt the database--the kind of corruption that requires a Decompile
to fix. You're safe if you End the code (Run menu), and then switch the form
to design view before editing its module.
 
G

Guest

I have a similar problem, and the recommended steps don't work. I recently
upgraded from Access 2000 to Access 2003, and the problem seems to have
started with the upgrade.

After going through the steps recommended, I get an error message after
issuing the call from the Immediate Window. The error message says that "The
Sub or Function is not defined."

I have saved the project, closed the file, and reopened it, and the code is
there. The code runs if I go to the form and trigger the associated event.

When I'm in the VB code editor, I note that the "View Code" icon in the
upppr left corner of the editor (in the "Project" pane) is not active, even
though the cursor is active in the code pane. If I click in the "View Code"
icon, the icon does not switch to an active state.

I can't figure out what I'm doing wrong. It sure would be a lot easier to
test and debug by stepping through the code directly in the VB editor instead
of toggling back to the form and clicking the button.
 

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