Link to home
Start Free TrialLog in
Avatar of BROOKLYN1950
BROOKLYN1950Flag for United States of America

asked on

vb. 4.5 code "skips same line" when not attached to file for debugging

I am doing a simple update of two tables in Access 2007 after I open a form on a button click event.  The routine  updates table 1, and I call a separate sub to update  table 2.  When the code runs it updates the first table but ignores the second update sub.

Originally I had both update actions in the same sub, ran into this problem and created two separate subs to see if it would help.

When I attach the form to the vb code to debug it, everything works 100%.  I can F10 through the code, table 1 updates, the second sub fires and updates  table 2.

I then put in message boxes to try and debug this without attaching the file. To my surprise, each message box showed up and the table 2 updates.

I rebooted the system, cleaned up the disk, etc  and the code still doesn't update that second table except when I attach the file and F10 through the code

This is bizarre behavior and costing me hours of agony.

Any Ideas?
Avatar of PatHartman
PatHartman
Flag of United States of America image

Post your code please.

OOPs.  I just noticed that this is actually a .net question.  I would suggest a .net forum instead since this is an Access forum.  You may be using Jet or ACE to hold your data but you are not using Access.
It seems clear this is a timing problem.  Have you tried putting a delay (sleep) in the code before the attempt to update the second table?  Even so, such a solution would be kludgey and unreliable.

It's hard to guess what the problem might be without seeing your code.  Certainly dividing one sub into two would make little difference as the second would run directly after the first without delay.  

I am guessing the second update action relies on changes made to another table in the first update.  If so, is there a way to rephrase the SQL (?) for the second update so it includes the changed values in the first update and does not rely on these being in the table?

Best wishes,
Graham Mandeno [Access MVP since 1996]
ASKER CERTIFIED SOLUTION
Avatar of BROOKLYN1950
BROOKLYN1950
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BROOKLYN1950

ASKER

Only one comment came in and I had solved it before that came in