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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help! Can't get to VBA window

Status
Not open for further replies.

DonLo

Technical User
Apr 24, 2001
36
0
0
US
I hope someone can help me! I've got an application which I was tinkering with, and I clearly screwed something up in the VB code, however, I can no longer access the code.

Normally, when, in the Properties window, I click on an "Event procedure" and click on the "..." next to it, VBA launches and opens to that section of the code. But now, nothing happens. So I can't even find my error.

I've tried to put in a new command button using the wizard, thinking I could then go to the VB code for that button, but when I attempt to do so, I get a "Subscript out of range" error message. What does this mean?

Is there some other way to open VBA and pull up the code associated with an appliction?

Thanks

Don
 
Create a new blank db, then import everything from the old one and open the probable culprit in Design View. This should give you access to the code window again.

TomCologne

 
Press "alt" + "f11", simultaneously.

Or, from design view, of a form, hit the icon, that looks like a square, with a red thingamajig, on the left bottom corner, yellow thingamajig on right bottom corner, and "flash" on top left corner. When you hover above it, it says "code".
Or from menu, go to view, then code.(from design view)

Good Luck!
 
Thanks TomCologne and dboulos,

Neither of your suggestions worked, but I have more information.

I opened another form in the database, and got to VBA that way. Looking at the Project Explorer in VBA, the form which is causing me problems is not even listed as a "Microsoft Access Class Objects" - the other two forms in the application are there. But the form is clearly present in my database - I can open it and there are many event procedures in the form.

Any other ideas?

Thanks!

Don
 
You've got me stumped, Don.
The only experience I have with "Subscript out of range", is when I try to reference an element in an array, when there isn't one, within the declared range.
Don't know how that applies here?
I assume you've tried all the obvious checks, rebooting etc...

Do you recall what your last manuoevre was before the lock-out? What event it was in, what the result was expected to be?

Sorry Don, I'm stumped?

 
Yes, I tried closing and reopening Access, and then completely rebooting the computer, but no help.

The last change I made was pretty simple. I had some code that I had previously commented out, and I was putting it back in. At one point, when I removed the ' before the first line of the commented out code, VBA automatically put in an "End Sub" line, which I missed, and then when I tried to run it, it gave me an error which said that I couldn't have code after the End Sub statement. However, I was able to remove the errant "End Sub" statement, and I thought that was it. I may have inadvertantly done something else.

Don
 
But, you're saying you can still, access the form in all views. Just from THAT form, you can't access the VBE window. And, even from the VBE, you can't access THAT forms' module?

So hypothetically, even if theoretically, you discovered the problem, you may not be able to fix it, due to inability to access the module to make the correction.

What was the event, was it OnCurrent? Was the code trying to close, or open a form?
 
Your statement of the problem is correct. I can access the form in all views, but I can't access the VBE window from THAT form, and even from VBE, I can't access THAT form's module. (Actually, using the Alt+F11 trick, I can get to the VBE window, but it is blank - no window for the the code I had previously entered.)

There are a lot of event procedures in this form, some for the form, some for specific controls on the form. There is definitely an OnCurrent event, but it wasn't to open or close the form. Rather it opened the form to a new record, and also contained commented out code (possibly - this is what I was tweaking) that set the date of a control on the form to Now()
 
I suspect some kind of corruption.

If that's the case, take some backups and try some of the things mentioned here thread702-873544 (you did try importing the objects to a new database?).

Roy-Vidar
 
Don

I was tinkering

Did you by chance create an MDE? (Probably not since you are looking at the Form properties.)

...and "backup" is a four letter word until you need it.

Create a new database, and import your tables, forms, etc.

If you suspect you know where the problem is, you may have to skip importing this component, and recreate it.

Richard
 
Thanks to everyone for your suggestions. I ended up getting a backup copy of the database from our network adminstrator. He suggested, that to avoid this problem in the future, I make sure to compile my code regularly - something I hadn't known to do.

Don
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top