p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning Access 2003 VBA (http://p2p.wrox.com/forumdisplay.php?f=150)
-   -   On Load: "Invalid Outside Procedure" (http://p2p.wrox.com/showthread.php?t=44705)

kritimehrotra June 30th, 2006 12:35 PM

On Load: "Invalid Outside Procedure"
 
Hi,
I have an error message popping up when I load a form, saying:

The expression On Load you entered as the event property setting produced the following error:
Invalid Outside procedure.
* The expression may not result in the name of a macro, the name of a user-defined function, or [Event Procedure]
* There may have been an error evaluating the function, event, or macro.

This is my entire function:

Private Sub Form_Load()
    NavigationButtons = False
End Sub

Also, this was working completely fine, until I added an array declaration in the Declarations section. Earlier, my declaration section only had:

Option Compare Database
Option Explicit

Now it has:

Option Compare Database
Option Explicit
Dim regions(1 To 8) As String
   regions(1) = "Atlanta"
   regions(2) = "GTA"
   regions(3) = "Huron Rideau"
   regions(4) = "North-West Territories"
   regions(5) = "Pacific"
   regions(6) = "Prairie(s)"
   regions(7) = "Quebec"
   regions(8) = "Other"

I added this because I would be using the array from other Subs in the module.

Could anyone tell me why this is giving me an error?

Thank you!
Kriti


kritimehrotra June 30th, 2006 01:01 PM

I just realized actually, that I'm getting the exact same error for EACH sub, not just the form_load() one. So any button that I click on, I get that error. Basically my form isn't able to do anything!


mmcdonal July 21st, 2006 07:21 AM

It has to do with lines of code outside your procedure. I will bet if you removed Option Explicit after Option Compare Database, this will prevent this error.

mmcdonal

peterlarsen March 1st, 2007 11:53 AM

I just came across this same issue - a very simple event procedure that worked fine until I declared and set a variable in the declarations section of the module. With a little experimenting, I found that it was OK to declare the variable, but that setting the variable in the declarations section caused the error to occur.

My workaround was to declare the variable in the declarations section and set it in the Load event of the form. This looks to be working just fine.

Peter Larsen
Altaveo, Inc.


All times are GMT -4. The time now is 09:33 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.