Reputation: 149
I have a database with a (modal) login form where an employee enters their Username and Password. After they log in, they will see another form, UserDashboard. I want to be able to have their First and Last name appear on the UserDashboard, but I can't figure out how to do it.
I'm using a DLookup on the Login form to find the employee's first and last name from the Employees table (where their username and password are also stored). Then I'm trying to display these variables on the UserDashboard, but since it's a separate form, there is nothing in the variables "First" and "Last" when UserDashboard loads.
Is there something I can do to place the First Name and Last Name on UserDashboard?
Code in the Login form:
First = DLookup("EmpFirstName", "Employees", "Username = '" & Me.txtUsername.Value & "'")
Last = DLookup("EmpLastName", "Employees", "Username = '" & Me.txtUsername.Value & "'")
Code for the UserDashboard form:
Private Sub Form_Load()
Me.txtDashboard = "User Dashboard - " & First & " " & Last
End Sub
Thanks!
Upvotes: 0
Views: 65
Reputation: 3723
Define the variables outside the form in a module and use them as global variables.
Public First As String
Public Last As String
Upvotes: 1