Invalid outside procedure

S

scott

In a general module, I have the below code that "Dims" a public variable,
then I sent that variable's value. I'd like to be able to reference that
variable from any of my vba code within Access.

I'm getting an "Invalid outside procedure" error because of this. How can I
set a Public variable and use it throughout my access vba code?

GENERAL MODULE **********

Public myPublicVar As String

myPublicVar = "testing"
 
K

Ken Snell \(MVP\)

The code step that is the problem is this one:

myPublicVar = "testing"

Just put that code step in a procedure.

If you want that variable to actually be a constant, then you'd change the
initial code step to this:

Public Const myPublicVar As String = "testing"
 
Top