Module not found

imaksu
imaksu used Ask the Experts™
on
On a form I create a button to open a form when I click I get the message "Module not found and the form is not opened.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
Top Expert 2007

Commented:
This is generally *not* a good sign ... and is usually corruption that may be able to be fixed by a repair service.  You can try a Compact & Repair ... but not likely to work.

You can also try importing all objects into a new MDB ... except for the corrupted form/module ... then recreate the form.

mx

Commented:
I think it is missing refference that file is using, try to design the form then view it's code  then click tools- references and see if any thing in the list is missing, notice the dll or ocx file it is using and check if it is missing from your file system, sometimes you can uncheck it and it will work if it is not used on your form

Commented:
Both of these guys are right, and to identify the specifics of the problem, you might need to see exactly what part of your button code is causing the error.  Different versions of access produce different "automatic" button scripts with their wizards.  In the VBA editor for that button code, press F9 on the first "executable" line of the code (not a Declaration statement) to set a debug BreakPoint.  Then when you click your button, Access will open the editor on that line and you can press F8 to step through the code and see what actual line is triggering the error message.  That could help you identify your specific problem.

When you're done, don't forget to go back to the VBA editor and toggle OFF the breakpoint (the highlighting will go away) so your code won't always stop at that point.
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
Top Expert 2007

Commented:
"Both of these guys are right, "

Well ... not exactly.  The problem here is ... the Form *cannot* be opened because of this error.  

So ... "try to design the form then view it's code" ... is not going to happen because the form cannot be opened.  In fact, it may not be possible to open any code ... 'depending'.  The entire mdb may be corrupted or just one form.   You're not going to be able to single step through any code.  Remember what the error is sayL

"Module Not Found"
              ^^^^^^^^^

mx

Commented:
Sorry I wasn't more specific.  First, I should have said "both of these guys COULD be right.

Now to the initial post...If I'm reading this right, there is a button on Form1 that calls code to open Form2.  When you click the button on Form1, then you get an error message.  

I'm assuming, perhaps incorrectly, that Form2 CAN be opened on its own through the Database window.  Is that true or false?

I'm also assuming that the error takes place while executing the code on Form1, which clearly can be opened, or you could click the button to trigger it.  Is this true or false?

So now the problem is POSSIBLY that the VBA module for Form1 is missing.  In that case, you'll learn something by opening the VBA editor and looking for it.  If it's gone (e.g. "not found" then you've definitely got MX's corruption issue.  Depending on your add-ins, access version, wizards, etc. you could also have something in your button code that is calling another module that is not found.

Either way, the first step is to attempt to view the VBA code for Form1.  Either you can, or you can't, and it's going to be diagnostic either way.
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
Top Expert 2007

Commented:
"Is that true or false?"
It probably cannot be opened from the db window.

The form most likely shows in the DB window ...

mx
Commented:
Sorry... accidentally clicked submit before I finished :-)
One more thing that you could learn from the VBA editor is if the problem was cause by an incomplete "rename" operation, where you renamed Form1, and the "automatic" rename of it's accompanying VBA module didn't happen.  In that case, you'll find a stray module shown in the left-hand pane of the editor under the "old" name of Form1, and you can just copy its code to the Form1 VBA module.
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
Top Expert 2007

Commented:
We need to hear from imaksu

mx

Author

Commented:
Thank you  all for comments: Action sequence for info:
1 Db opens --> Logon with shift pressed
2 Click on Form1 --> Form 1 opens
3 Click on Button 1 for Form 2 --> "Module Not Found"
4 Click on OK --> Vba code appears. On Vba page code for the button seems normal but the cursor is on the top line "Option Compare Database" instead of being in the area for button subroutine.
5 Close Vba code --> "This command will stop the Debugger."
6 Click on Form 2 --> Form opens normally, showing data.
Thanks  
Infotrakker Software
Most Valuable Expert 2012
Top Expert 2014
Commented:
This sounds like you have VBA container corruption. I'd immediately make a backup and try the remedies proposed earlier (i.e. compact/repair, or import into a new db).

You can also try the undocumented SaveAsText/LoadFromText methods, if you find that you have a corrupt object or objects. To do that, from the Immediate window:

SaveAsText(acForm, "YourFormName", Currentproject.path & "\YourFormName.txt")

Press the enter key, then make sure the file was created at the path indicated. Now delete the offending form, close and re-open the database, and do this from the Immediate window:

LoadFromText(acForm, "YourFormName", Currentproject.path & "\YourFormName.txt")

This should re-create the form from the text base, which can often remove any corruption.

You could also have issues with your installation of Access/Office, or Windows. Make 100% certain that they are all up to date.

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
Top Expert 2007

Commented:
I can't recall a time when 'module not found' was anything other than corruption.

mx

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial