Session Variables type thingies

clive2002

Registered User.
Local time
Today, 13:19
Joined
Apr 21, 2002
Messages
91
I need to store the users login and various security rights and refer to them throughout the user session as values in queries and VBA code in forms.

How do i store these variables so that they can be called? I need something like session variables in ASP.
 
In Access, you use Global Variables to accomplish the same thing. Declare Global Variables in a Global Module, e.g.


Public gbStrName as string
Public gbIntCount a integer
Public gbLngTableID as long
Public gbVarDontKNow as variant

if you have any further questions, let me know.
 
In the 21st century, you use "Property" procedures instead of global variables.

Create a module, call it "modProperties".

In the module:

Private PstrYourString As String

Public Property Get GetYourString() As String
GetYourString = PstrYourString
End Property

Public Property Let LetYourString(ByVal vNewValue As Variant)
PstrYourString = vNewValue
End Property

Technically, you can use the same function name for both the Get and the Let but I find that confusing so I add "Get" or "Let" as part of the name.

In other code you refer to the Property functions, *n*o*t* the variable names.

LetYourString() = "Hi There"
Form![SomeTextBox] = GetYourString()

On the form, SomeTextBox will display "Hi There".

You can also use a "Get" as criteria in a query. This decouples the query from any Form name.

To the future,
RichM
 
Thanks guys,

I'll try both methods and see which works best for me, Rich's method made my head hurt more so that will probably end up being the one i have to use.
 

Users who are viewing this thread

Back
Top Bottom