How do i make a Variable that is specific to a form to a global Variable. i want to save the name of the person who logs in (via a login screen that i made) , so that i can stamp some there activity within the database to that name.
I'm not sure here, but you're probably right. Maybe you can change it to a global variable, and assign it a value when they login. Just put the word "global" in front of the variable in a separate module, so it can be assigned the value when the user logs in. Could this work, I wonder...??How do i make a Variable that is specific to a form to a global Variable. i want to save the name of the person who logs in (via a login screen that i made) , so that i can stamp some there activity within the database to that name.
You don't have to assign a module to the button. If you have a module with this in it:how do i assign the module to the login button? i see it there but i cannot add it how do i do it?
global MYVALUE as string
MYVALUE = me."Login"FormControlName
Private Sub Ok_Click()
Static LogonAttempts As Integer
Dim SaiCurrentUser As String
SaiCurrentUser = ""
If Me.Password.Value = DLookup("[Password]", "[User Name]", "[User Name] = '" & Me.User_name & "'") Then
SaiCurrentUser = [User Name]
DoCmd.Close acForm, "Login Screen", acSaveNo
DoCmd.OpenForm "Switchboard"
Else
LogonAttempts = LogonAttempts + 1
MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
"Invalid Entry!"
Me.Password.SetFocus
Me.Password.Value = ""
End If
If LogonAttempts > 3 Then
MsgBox "You do not have permission to access this database.Please contact your database administrator."
Application.Quit
End If
End Sub
Global SaiCurrentUser As String
Private Sub Ok_Click()
Static LogonAttempts As Integer
Dim SaiCurrentUser As String
SaiCurrentUser = ""
If Me.Password.Value = DLookup("[Password]", "[User Name]", "[User Name] = '" & Me.User_name & "'") Then
SaiCurrentUser = [User Name]
DoCmd.OpenForm "InfoKeeper"
Forms![InfoKeeper]![Loginname] = SaiCurrentUser
DoCmd.Close acForm, "Login Screen", acSaveNo
DoCmd.OpenForm "Switchboard"
Else
LogonAttempts = LogonAttempts + 1
MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
"Invalid Entry!"
Me.Password.SetFocus
Me.Password.Value = ""
End If
If LogonAttempts > 3 Then
MsgBox "You do not have permission to access this database.Please contact your database administrator."
Application.Quit
End If
End Sub