Breakpoint - does it change your results?

G

GHawkins

I am working with some VBA code that I didn't write. Since upgrading to SQL
2005, something within the code isn't working exactly like it used to (big
surprise). We're running Access 2003 SP2.

When trying to debug the issue. I've noticed that if I put my breakpoint on
a certain line (let's say line 85) or before, the code works as expected
(more specifically, I'm trying to bookmark a new entry so that when the form
inserts the data and opens, it pulls up the newly added entry).

However, if I put the break on line 86 or after, the code doesn't work. My
bookmark is lost, and the first item is returned.

I have noticed that if I put the break on line 86 or after, and look for the
bookmark value in the Locals window, the value is not lost.

Does any of this make sense, or is it just a coincidence?
 
M

Marshall Barton

GHawkins said:
I am working with some VBA code that I didn't write. Since upgrading to SQL
2005, something within the code isn't working exactly like it used to (big
surprise). We're running Access 2003 SP2.

When trying to debug the issue. I've noticed that if I put my breakpoint on
a certain line (let's say line 85) or before, the code works as expected
(more specifically, I'm trying to bookmark a new entry so that when the form
inserts the data and opens, it pulls up the newly added entry).

However, if I put the break on line 86 or after, the code doesn't work. My
bookmark is lost, and the first item is returned.

I have noticed that if I put the break on line 86 or after, and look for the
bookmark value in the Locals window, the value is not lost.


I don't use SQL Server so I probably can't tell exactly what
might be wrong. However, the BreakPoint effect is a fairly
clear indicator of a race condition between your code and
some asynchronous activity (e.g. RunSQL). Try looking back
from line 85 to see if there is something that is updating.
 
G

GHawkins

There is an Insert statement, and then a Find statement to get the recently
added item. Is there any way to put a "pause" or something in the code, just
to see if Access needs a little more time to sync everything up?
 
M

Marshall Barton

Not that I know of, but that doesn't mean much if you're
using ADO.

I'll take a guess that your "Insert" is using an
asynchronous method, in which case the answer would be to
use the synchronous Execute method instead.

The FindFirst and Find methods are synchronous so that is
not an issue. If you are using ADO then you probably should
be using SELECT @@IDENTITY instead of Find.
 

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