How can I set global variables?

  • Thread starter Thread starter Mendel8
  • Start date Start date
M

Mendel8

Guest
If I write code in a form with a textbox (txtSample.text) then is there a way I can set that globaly so I can reference it in a seperate module?

I don't know if this is possible but I'd appreciate any insight.

Thanks.
 
In a module you define a global variable by dimming it with the Public keyword.

Public txtGlobal As Text

it is then available in any module anywhere. So in the AfterUpdate event of the control in your form you'd assign the value to the global variable:

txtGlobal = Me.txtSample
 
If you Declare a public variable at the top of a Class module (the code belonging to a specific form), the variable will be accessible to all of the subroutines and functions in that form/class module.

If you want your variable to be used across multiple forms, you will need to create a standard module (in the modules tab of the database) and declare it there.

HTH

Mike
 

Users who are viewing this thread

Back
Top Bottom