Invalid outside procedure

  • Thread starter Thread starter scott
  • Start date Start date
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"
 
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"
 

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

Back
Top