I want to insert OfficerID of the officer currently logged in as a default value into the table T_FileCases.
Already in the login form I have a field that holds officer's name (UserName) when they are logged in successfully but when this happens I also want to automatically insert their OfficerID into the table T_FileCases automatically, instead of using a combo box for selecting officers name when creating a new case.
Me.Hold_User_ID = Nz(DLookup("OfficerID", "Table_Officers", "Names='" & Me.UserName & "' and NRC='" & Me.PWD & "'"), -1)
' check to see if we have a good login
If Me.Hold_User_ID = -1 Then
MsgBox "Sorry boss, you typed invalid username or password.", vbExclamation
Exit Sub
Else
' load the users access level into the holder form field
Me.hold_level = DLookup("Access_Level", "Table_Officers", "Names='" & Me.UserName & "' and NRC='" & Me.PWD & "'")
End If