What to do when Code works when Stepping through but doesn't when

  • Thread starter ThriftyFinanceGirl
  • Start date
T

ThriftyFinanceGirl

Okay, This is beyond crazy, but I think I've heard of this happening before.
I have code running during generating a report, lots of scenarios and
exceptions. Every once in a while when I rerun on month, it will totally
mess up one of the calculated numbers, therefore throwing off the entire
report. However, If I STEP THROUGH the code it ALWAYS saves the number
correctly. How am I supposed to debug this if there is no way to FIND the
error?

HELp!
 
J

Jeff Boyce

I, too, ran into a situation in which Access would ocassionally mess up ...
nothing consistent.

Turned out that the one common factor was that this always happened to
someone who was using a front-end on a PC located 45 miles away. No, they
weren't on a WAN, which is known to cause problems, but on a LAN that
includes those further-away workstations.

When I modified that stretch of code to complete one step before attempting
to run the part that broke, the problem disappeared.

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
T

ThriftyFinanceGirl

So how do I do that "modify that stretch of code to complete one step before
attempting to run the part that broke"? Is that just the "Do Events" command?
 
J

Jack Leach

Is that just the "Do Events" command?

AFAIK, that is correct.

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
J

Jeff Boyce

In my situation, the DoEvents command was not what I needed. It wasn't that
the code needed to let the PC do something else, it was that the specific
step in the code involved retrieving some data (from 40 miles away). My
line of code went something like:

'p-code
get the data from the database and use it in this expression
next step

The code failed at "next step" because the data didn't always make the trip
quickly enough.

I modified the code to do something like:

'p-code
get the data from the database and put it in VariableX
use VariableX in this expression
next step

The act of setting VariableX to the value was sufficient to get Access to
complete that part before moving on.

Good luck!


Regards

Jeff Boyce
Microsoft Office/Access MVP
 
R

ryguy7272

Bizarre! What if you check Tools > Options > Compact on Close. Close it,
open it, and rerun?

Good luck,
Ryan---
 
T

ThriftyFinanceGirl

Ryan, I have done that too... I thought that might help but no luck!
 
T

ThriftyFinanceGirl

That makes sense... making it stop to get the value definitively before
moving on. I will try something like that. That is the only thing that I
can think of is that when running the code on it's own it "skips" something
but when stepping through it, it has time to get it.
 
R

ryguy7272

Hummm, maybe that's it. Maybe there is something weird with your RAM,
preventing Access from keeping up with itself. It's a long shot, but can you
down the computer, wait a few minutes for the current to totally run out of
the computer, maybe even unplug it, boot up, and retry. It's a long shot,
but I suppose you've got nothing to lose.

HTH,
Ryan---
 
T

ThriftyFinanceGirl

I did do that and no help, but I'm going to test on another machine.
However, for the moment I "Moved" part of the code to a different section and
it seems to have "fixed" it. It was just missing/jumping over part of the
code. Still don't understand it though, but I'm going to play with it later
 
T

Tony Toews [MVP]

ryguy7272 said:
Hummm, maybe that's it. Maybe there is something weird with your RAM,
preventing Access from keeping up with itself. It's a long shot, but can you
down the computer, wait a few minutes for the current to totally run out of
the computer, maybe even unplug it, boot up, and retry. It's a long shot,
but I suppose you've got nothing to lose.

I doubt very much this is a RAM problem. RAM is exceedingly fast
compared to the hard drive which in turn is exceedingly fast compared
to a LAN then WAN connection.

Tony
 

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