thinair421
Registered User.
- Local time
- Today, 01:44
- Joined
- Jun 22, 2010
- Messages
- 34
Hey everyone,
I currently have a login form. Consists of a username combo box which gets the UserID and UserName from a table (call this the UserName table...the UserLog table is different!...see below). Below is a password form, which of course the user enters. Upon clicking the Login command button, a check is performed via the following code:
I would like to know how I would go about making a user log, which logs the date/time & and the username based off what is selected/entered into this form. I have attempted setting my control source for my username combo box to a field in my userlog table (to store the name), along with adding a hidden date box in the background of the login form (to track the date). Seems to work just fine...but not quite.
The UserLog table which should be storing this data has 3 fields:
1)LoginID - autonumber (primary key)
2)Date/Time - saves date and time
3)Username - saves username
It will make one entry (i.e. Autonumber 1), but any entry after that overwrites the previous (only overwrites the username)...essentially I only have one row of data that is constantly being updated/overwritten. Why does it only create one record. Thanks so much in advance.
I currently have a login form. Consists of a username combo box which gets the UserID and UserName from a table (call this the UserName table...the UserLog table is different!...see below). Below is a password form, which of course the user enters. Upon clicking the Login command button, a check is performed via the following code:
Code:
Private Sub OK_Click()
On Error GoTo Err_OK_Click
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboEmployee.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If
'Check value of password in tblEmployees to see if this
'matches value chosen in combo box
If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", _
"[lngEmpID]=" & Me.cboEmployee.Value) Then
lngMyEmpID = Me.cboEmployee.Value
'Close logon form and open splash screen
DoCmd.Close acForm, "frmLogon", acSaveNo
DoCmd.OpenForm "SWITCH"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
"Invalid Entry!"
Me.txtPassword.SetFocus
End If
Exit_OK_Click:
Exit Sub
Err_OK_Click:
MsgBox Err.Description
Resume Exit_OK_Click
End Sub
I would like to know how I would go about making a user log, which logs the date/time & and the username based off what is selected/entered into this form. I have attempted setting my control source for my username combo box to a field in my userlog table (to store the name), along with adding a hidden date box in the background of the login form (to track the date). Seems to work just fine...but not quite.
The UserLog table which should be storing this data has 3 fields:
1)LoginID - autonumber (primary key)
2)Date/Time - saves date and time
3)Username - saves username
It will make one entry (i.e. Autonumber 1), but any entry after that overwrites the previous (only overwrites the username)...essentially I only have one row of data that is constantly being updated/overwritten. Why does it only create one record. Thanks so much in advance.
Last edited: