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

"Invalid Outside Procedure?"

Status
Not open for further replies.

ktodaitty

MIS
Apr 22, 2003
19
US
Hey guys.

This keeps happening to me; I have been trying to design a contact management system for some time now and after writing some code keep getting a message box saying "The expression [variable] you entered as the event property setting produced the following error: Invalid outside procedure." It is not only my code that is doing this but also the wizards', for example the one you use when creating a command button. What gives?

Thanks in advance.
 
It's a shame that you haven't posted an example of your code.

The error message that you are getting is usually because text/code is as the message states being written outside a procedure.

Procedures that I can think of start with:

Sub
Private Sub
Public Sub

And all end with:

End Sub

If any text/code appears between End Sub and Sub etc this will cause the message that you are receiving.

If this doesn't solve the problem, post your code and point out what is highlighted when getting this message.

Bill
 
Bill,

Thanks for the timely reply. When I get the message and I hit the OK (of course I am required to) there is nothing highlighted in the code. I have gone back through it and can find nothing out of sync. What's more, I am getting the message for every procedure I have attempted to write code for.

Cat
 
Have you got a Function or Procedure named the same as your DB or an Object in the DB (Form, Module etc), that could also cause this error.

eg, if you had a Module called ktodaitty and a Sub or Function called ktodaitty, this would cause problems.

Bill
 
Bill, I can't find any of the instances you mention. Maybe something is wrong with my code:

Private Sub cmdNonPaper_Click()
On Error GoTo Err_cmdNonPaper_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "NonPaperLAO_CW_Main"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdNonPaper_Click:
Exit Sub

Err_cmdNonPaper_Click:
MsgBox Err.Description
Resume Exit_cmdNonPaper_Click

End Sub

However, as I mentioned it has been giving the same message for every piece of code I try to write.
 
Hi ktodaitty,

Could you make a copy of your DB, remove any sensitive records from your tables, zip it up and Email to me at billpower@cwcom.net . I'll get back to you ASAP with any suggestions in this Thread.

Bill
 
Bill,

I'd be glad to. How do I "zip it up?"

Cat
 
Just email the DB file as is. You need Winzip Software to zip up a File.

Cheers

Bill
 
Hi Cat,

Got your DB, unfortuneately, couldn't open it. I'm still using Access 2000, Could you convert your Copy DB to Access 2000, test it in 2000 Format to see if you still get the Error and send it to me again please.

In Access 2000, to Covert to a Prior Version > from the Menu, select Tools>> Database Utilities. Hopefully it's similar in your Version.

Thanks

Bill

 
Hi,

Open the Form "Switchboard" in Design View. From the Menu, select View->> Code, the VB Editor will be displayed, this is causing the problem:

Option Compare Database

End Sub 'Delete this Line

Private Sub cmdLAO_DocMan_Click()


Scroll to the top of the screen, you have "End Sub" without one of the Subs I listed yesterday.

Also, in this Module this Sub has an error:

Private Sub cmdLAO_DocMan_Click()
On Error GoTo Err_cmdLAO_DocMan_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "DocManageMain"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdLAO_DocMan_Click:
Exit Sub

Err_cmdLAO_DocMan_Click:
MsgBox Err.Description
Resume Err_cmdLAO_DocMan_Click 'this line was misspelt change to this

End Sub

Delete the Module "Switchboard", somehow it's just a duplicate of your code in the Form "Switchboard".

Lastly, your DB seriously needs Compacting. From the Menu - Tools->> Database Utilities->> Compact and Repair Database (maybe slightly different in your Version)

Will Email working Version with these changes implemented.

Good Luck

Bill
 
Thanks so much, Bill! I guess I will develop a better eye for detail with more experience....

Take Care,
CAT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top