Module Not Found

G

Guest

I have written code for a cancel button that I have on my form - when I close
VB and press the cancel button I receive the error message "Module Not Found"


Here is the code that i have for the cancel button

Private Sub cmdCancel_Click()
DoCmd.Close acForm, "frmReroutes_Report_By_Contact"
End Sub



Now when i was typing the code in instead of getting the options boxes,
example, when I typed DoCmd. I got an error message stating "You canceled the
previous operation"

What am I doing wrong.
 
A

Allen Browne

Something has gone wrong with the naming, or there is some other operation
in progress.

Try undoing whatever is happening, and use the name that Access knows the
form by:
If Me.Dirty Then
Me.Undo
End If
DoCmd.Close acForm, Me.Name
 
G

Guest

where exactly am I putting that - I opened up VB going through the cancel
button that I was having the problem with. When i tried to type it up I
still kept getting the error message "You canceled the previous operation"
Because I am really new at this I don't have a clue :) This is what I was
typing

If Me.Dirty Then
Me.Undo
End If
DoCmd.Close acForm, Me.frmReroutes_Report_By Contact
 
A

Allen Browne

The 4 lines of code go into the event procedure for your command button,
instead of the 1 line in your original post.

The error message could be related to something else that is going on, e.g.
another event that is still running (such as the Exit of another control,
before Access moves focus to the button and starts processing its Click
event.) To test that idea, add this line above the other 4:
Stop

Now when it runs, if Access stops on the line, you know the event is
working. You can then press F8 to single-step through the procedure and see
where the problem lies.
 
G

Guest

I added the following:

Private Sub cmdCancel_Click()
Stop
If Me.Dirty Then
Me.Undo
End If
DoCmd.Close acForm, Me.frmReroutes_Report_By_Contact
DoCmd.Close acForm, "frmReroutes_Report_By_Contact"
End Sub

and when I try to press the button I now get this error:

The expression On Click you entered as the event property setting produced
the following error: Invalid outside procedure
 
A

Allen Browne

There is something else wrong here.

In the code window, choose Compile on the Debug menu.
Fix any issue that Access highlights.
Repeat until the code compiles okay.
 
G

Guest

When I do the compile, it doesn't show me what is wrong just gives me the
error messages "You canceled the previous operations" and "Module Not Found"
It's not showing me where the error is occuring
 
A

Allen Browne

That either indicates that you have some code running, or else that the code
is corrupt.

1. Close the database.

2. Start Access again, holding down the Shift key if you have anything that
automatically starts when you load.

3. Uncheck the boxes under:
Tools | Options | General | Name AutoCorrect
Explanation of why:
http://allenbrowne.com/bug-03.html

4. Compact the database:
Tools | Database Utilities | Compact/Repair

5. Close Access. Make a backup copy of the file. Decompile the database by
entering something like this at the command prompt while Access is not
running. It is all one line, and include the quotes:
"c:\Program Files\Microsoft office\office\msaccess.exe" /decompile
"c:\MyPath\MyDatabase.mdb"

6. Open Access (holding down the Shift key if you have any startup code),
and compact again.

7. Open a code window.
Choose References from the Tools menu.
Uncheck any references you do not need.
For a list of the ones you typically need in your version of Access, see:
http://allenbrowne.com/ser-38.html

8. Still in the code window, choose Compile from the Debug menu.
Fix any errors, and repeat until it compiles okay.

At this point, you should have a database where the name-autocorrect errors
are gone, the indexes are repaired, inconsistencies between the text- and
compiled-versions of the code are fixed, reference ambiguities are resolved,
and the code syntax is compilable.

If it is still a problem, the next step would be to get Access to rebuild
the database for you. Follow the steps for the first symptom in this
article:
Recovering from Corruption
at:
http://allenbrowne.com/ser-47.html
 

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