I am totally new to access 2007. I have created a logon form that gets data from a "Employees" table.
I want to add logon date and time information to the same row of a logged on user. If possible add the logout date and time too.
Is it better to create a second table or possible to do everything in one table..?
herewith the logon code used:
----------------------------------
Expand|Select|Wrap|Line Numbers
- Option Compare Database
- Private Sub cmdLogin_Click()
- 'set the variable for the invalid login retry
- Static intLogonAttempts As Integer
- 'Check to see if data is entered into the UserName combo box
- If IsNull(uname) Or uname = "" Then
- MsgBox "You must choose a User Name.", vbOKOnly, "Required Data"
- uname.SetFocus
- Exit Sub
- End If
- 'Check to see if data is entered into the password box
- If IsNull(passw) Or passw = "" Then
- MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
- passw.SetFocus
- Exit Sub
- End If
- 'Check value of password in tblEmployees to see if this
- 'matches value chosen in combo box
- If passw.Value = DLookup("Password", "Employees", _
- "[ID]=" & uname.Value) Then
- ID = uname.Value
- 'Close logon form and open Control Panel screen
- 'CurrentDb.Execute "INSERT into Employees (LogonDate) VALUES (date())"
- DoCmd.Close acForm, "LogonForm", acSaveNo
- DoCmd.OpenForm "Control Panel"
- intLogonAttempts = 0
- Else
- MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
- "Invalid Entry!"
- intLogonAttempts = intLogonAttempts + 1
- passw.SetFocus
- End If
- 'If User Enters incorrect password 3 times database will shutdown
- If intLogonAttempts > 3 Then
- MsgBox "You do not have access to this database.Please contact admin.", _
- vbCritical, "Restricted Access!"
- Application.Quit
- End If
- End Sub
The table is called "Employees"
with fields:
ID - Autonumber
FullName - Text
Password - Text
LogonDate - Date/Time
Thanking you in advance,
Bongazi