Click to See Complete Forum and Search --> : Access Form


computerman29651
November 19th, 2007, 04:50 PM
I am trying to create a type of Clock-In Form in Access 2003. What I would like the form to do is the following: Once the user has entered his/her username and password, click the clock-in command button, the form will check to see if the employee exists. If the employee does exist in the tblEmployee Table, then the username, clock-in date, clock-in time will be semt to the tblClockIn Table. The same will be for the Clock-Out command button, except with the clock-out date and time.

Here is the code I have so far:



Option Explicit
Option Compare Database
Private intLogonAttempts As Integer
Public lngMyEmpID As Long

Private Sub Form_Open(Cancel As Integer)
'On open set focus to combo box
Me.cboEmployee.SetFocus
intLogonAttempts = 0
End Sub

Private Sub cboEmployee_AfterUpdate()
'After selecting user name set focus to password field
Me.txtPassword.SetFocus
End Sub

Private Sub cmdLogin_Click()

'Check to see if data is entered into the UserName combo box

If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
MsgBox "User Name is a required field.", 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 "Password is a required field.", 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

DoCmd.Close acForm, "frmLogon", acSaveNo





End Sub