Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass fields to other forms

Status
Not open for further replies.

zrobinso

MIS
Apr 22, 2001
27
0
0
US
How can I pass two fields that I use on my login form to every filter other forms that are opened by a userID (multiuser environment). After login, a switchboard form is opened and the login form is closed.

The two fields on my login form are:

[txtUserID]
[txtUserNumber]
 
Create a Global variable for each and a Function for each at the database Module level.
Code:
Global vUserID as String
Global vUserNumber as Long

Function UserID()
  UserID = vUserID
End Function

Function UserNumber()
  UserNumber = vUserNumber
End Function


Now in the LogIn form behind a OK Button or whatever you use to finish the login put the following code:
Code:
vUserID = me![UserID]
vUserNumber = me![UserNumber]


This assumes that the form objects with the data that you want to save and have available through the database is the form objects:

me![UserID] and me![UserNumber]

Now by a simple function call to these two values you have access through out your database including queries.

UserID()
UserNumber()

Does this sound like what you need?

Bob Scriver
 
My pleasure. I use this global variable and function alot.

Bob Scriver
 
Just curious, why the function to retrieve the gloval variable and not a function to set the value?

Nonny
 
leebase:The global variable can be set with a simple command:

vGlobalVariable = assignmentvalue

The global variable can be accessed in all forms, reports, and modules but it cannot be accessed in queries. By retrieving it with the Function statement it can be used in expressions and criteria lines in queries.

Does this help?

Bob Scriver
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top