Let's see, on the change user password form has just the simple embedded Marco (save prompt). It is linked to my user table (it stores the loginID, password, and usertype).
The following code is set for when you hit Ok on the Login Form:
Option Compare Database
Private i As Integer
Private Const maxi As Long = 0
Private Sub Command1_Click()
Dim User As String
Dim AccessLevel As Integer
Dim TempPass As String
Dim ID As Integer
Dim WorkerName As String
Dim TempLoginID As TempVar
Dim DepartmentID As Integer
Static i As Integer
If IsNull(Me.txtUserName) Then
MsgBox "Please Enter LoginID", vbInformation, "LoginID Required"
Me.txtUserName.SetFocus
ElseIf IsNull(Me.txtPassword) Then
MsgBox "Please Enter Password", vbInformation, "Password Required"
Me.txtPassword.SetFocus
Else
If (IsNull(DLookup("LoginID", "tblworker", "LoginID = '" & Me.txtUserName.Value & "' And password = '" & Me.txtPassword.Value & "'"))) Then
MsgBox "Invalid LoginID or Password!"
i = i + 1
If (i = 3) Then
MsgBox "Maximum # of Attempts Reached. Contact Database Administrator.", vbOKOnly
DoCmd.Quit
End If
Else
TempVars!TempLoginID = Me.txtUserName.Value
WorkerName = DLookup("[workername]", "tblworker", "[LoginID] = '" & Me.txtUserName.Value & "'")
TempPass = DLookup("[password]", "tblworker", "[LoginID] = '" & Me.txtUserName.Value & "'")
ID = DLookup("[workerid]", "tblworker", "[LoginID] = '" & Me.txtUserName.Value & "'")
AccessLevel = DLookup("[UserType]", "tblworker", "[LoginID] = '" & Me.txtUserName.Value & "'")
Dim stDocName As String
DoCmd.SetWarnings False
stDocName = "qryLogInTimes"
DoCmd.OpenQuery stDocName, acNormal, acEdit
DoCmd.SetWarnings True
If Not IsNull(DLookup("[Deptname]", "tblworker", "[LoginID] = '" & Me.txtUserName.Value & "'")) Then
DepartmentID = DLookup("[Deptname]", "tblworker", "[LoginID] = '" & Me.txtUserName.Value & "'")
End If
DoCmd.Close
If (TempPass = "password") Then
MsgBox "Please Change Password", vbInformation, "New Password Required"
DoCmd.OpenForm "frmworkerinfo", , , "[workerid] = " & ID
Else
DoCmd.OpenForm "NavigationF"
Forms![NavigationF]![txtLogin] = TempVars!TempLoginID
Forms![NavigationF]![txtUser] = WorkerName
Forms![NavigationF]![txtSecurity] = AccessLevel
'call security level from sub function below
Call Security(AccessLevel, DepartmentID)
End If
End If
End If
End Sub