mistyinca1970
Member
- Local time
- Today, 11:30
- Joined
- Mar 17, 2021
- Messages
- 117
Can I simply reuse my login form to switch users. My question is basically, if I assign a Temp Vars, does it replace any existing Temp vars, or is there another bit of code I'll need to use to clear the old Temp Vars first?
Here is the code for my login form:
Here is the code for my login form:
Code:
Private Sub btnLogin_Click()
Dim rs As DAO.Recordset
Dim db As Database
Set db = CurrentDb
Set rs = db.OpenRecordset("qryLoginAccess", dbOpenSnapshot, dbReadOnly)
rs.FindFirst "Username='" & Me.txtUserName & "'"
If rs.NoMatch = True Then
Me.lblIncorrectLogin.Visible = True
Me.txtUserName.SetFocus
Exit Sub
End If
Me.lblIncorrectLogin.Visible = False
If rs!Password <> Me.txtPassword Then
Me.lblIncorrectLogin.Visible = True
Me.txtPassword.SetFocus
Exit Sub
End If
Me.lblIncorrectLogin.Visible = False
TempVars("UserType") = rs!UserAccess_ID.Value
TempVars("EmailAddress") = Me.txtUserName.Value
If rs!UserAccess_ID = 1 Then
Dim prop As Property
On Error GoTo SetProperty
Set prop = CurrentDb.CreateProperty("AllowBypassKey", dbBoolean, False)
CurrentDb.Properties.Append prop
End If
SetProperty:
DoCmd.OpenForm "frmUpcomingContracts"
DoCmd.Close acForm, Me.Name
End Sub