recordset problem

action

Registered User.
Local time
Today, 18:51
Joined
May 29, 2003
Messages
89
I am creating a timeclock for sign in and signout. I need to check that the employee record is not already signed in (forgotten to sign out) before they sign in again.

I have a simple table with employeeid, signin and signout date/time.

How can I add to this code so that it checks for prevoius records where the signout record is null and the employeeid equals the loaded id

my inital code is:

Private Sub Cmdsignin_Click()
'this writes to the hours worked table - sign in
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("TBLhoursworked", dbOpenDynaset)
rs.AddNew
rs![Signin] = Me![TxtCurrenttime]
rs![EmployeeID] = Me![TXTCurrentloggedon]
rs.Update
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
DoCmd.Close acForm, "FRMtimeclock", acSaveNo
End Sub

Thanks.
 
action,

I don't agree with the psychology here, but ...

You can use the DLookUp function to check for it by:

Code:
Dim IsOK As Variant

IsOK = DLookUp([WhoIsIt], "TBLhoursworked", "[User] = '" & Me.TXTCurrentloggedon & "'")

If IsNull(IsOK) Then
   MsgBox("You Do Not have a record.")
End If

Wayne
 

Users who are viewing this thread

Back
Top Bottom