Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access jumps into the VBA code editor for no reason

Status
Not open for further replies.

PeteJohnston

Programmer
Nov 6, 2002
291
GB
At times when my users are working with an Access application it jumps into the VBA code editor for no reason. I say no reason but really I mean I don't know why it does it. There are no errors, no break points, the user isn't debugging the code. In fact, when he sees the VBA behind the scenes he almost flipped. I get the same thing when I run it.

I haven't opened the code window at any time and I can't have a user in there. What if he deleted some of the code by mistake?

I hope someone can come up with a reason. I can't think of keys to put in the search without giving me hundreds of hits that aren't relevant.

PeteJ
(Contract Code-monkey)

It's amazing how many ways there are to skin a cat
(apologies to the veggies)
 
You could try opening the VBA IDE and going to Tools|Options|General tab. See what you have checked in the "Error Trapping" box.
If the VBA is well-written it will have error handlers in the code, so you would only need to have "Break on Unhandeled Errors" checked there.

Beir bua agus beannacht!
 
I prefer Break in Class Module myself but break on unhandled has its uses too. My VBA is always well-written with error trapping showing what the error is and where it occurred. I very rarely use On Error Resume Next and certainly not in this case so if I temporarily comment out the On Error Goto line it should kick up an error if it finds one. It doesn't.

The problem is that there isn't an error. It's like having a break point without the break point. It stops at a line of code and if I hit F5=Continue it goes on its merry way and runs the rest of the Form_Load routine. It isn't even consistent. Sometimes it runs normally and displays the form without any problems, sometimes it stops halfway through the Form_Load routine showing the VBA.

It confuses the bejaysus out of my users when a window pops up with some foreign language [bigsmile]

PeteJ
(Contract Code-monkey)

It's amazing how many ways there are to skin a cat
(apologies to the veggies)
 
I've had this in the past where it seems to remember an old break point, even if the code around it has changed. I think it's a form of corruption.
Try compiling the code (Debug -> Compilie VBA Code), compacting and repairing the database, exporting the code to a file then deleting the module and reimporting it or, as a last resort, reimporting everything into a blank database file.

hth

Ben

----------------------------------------------
Ben O'Hara
David W. Fenton said:
We could be confused in exactly the same way, but confusion might be like Nulls, and not comparable.
 
Remembering an old break point seems likely. I had been checking that it ran through the code like I expected. I'll try the Compile/Compact&Repair option but how do I test that it works? [ponder]

It's not consistent so I won't know if it works because I've fixed it or because Access has decided to let me have one pain-free day [dazed]

Ben O'Hara said:
iConfusion = Nz(TheNumberAccessFirstThoughtOf * Rnd, Err.Number)
[bigsmile]
 
Ben
You were on the right line there.

I put a break point in Form_Current in one of the forms, made a change to the form (added a blank character to the code) and saved it. I then closed the database. I then went back in and when I opened the form it stopped at the point where I'd put the break point. Added the same blank to the code, no break point this time, saved the form then closed/reopened the database and when I opened the form hey-presto, no code window!

Result!

PeteJ
(Contract Code-monkey)

It's amazing how many ways there are to skin a cat
(apologies to the veggies)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top