So I've been searching for the answer to my problem with no luck. I will make a simple version of what I need to do to make this question easier to ask.
I have 2 tables,
table 1 is [Employees] with Fields [Name] and [Passcode]
table 2 is [Clockedhours] with fields [Employee] , [Date of Work] , [Start Time] , [End Time]
I have one Form with 2 buttons Login and Logout, when pressed brings up an Input box asking for passcode for the user to login.
What I want it to do is search [Employees] for the passcode, if it matches a code then i want it to use that [Employee] to make a record in [Clockedhours] if it is a login, or if it is a log out i want it to find the record based on the employee and edit it to add the [end time].
What I got so far....
Private Sub Command2_Click()
Dim passkeybox As String
passkeytitle = "Enter passkey to clock in....."
passkeymsg = "Passkey Box"
passkeybox = InputBox(passkeytitle, passkeymsg)
If passkeybox = "12345678" Then
Dim dbtimecard As DAO.Database
Dim rstclockedhours As DAO.Recordset
Set dbtimecard = CurrentDb
Set rstclockedhours = dbtimecard.OpenRecordset("clockedhours")
rstclockedhours.AddNew
rstclockedhours("Employee").Value = "Testname"
rstclockedhours("Date of Work").Value = Date
rstclockedhours("Start Time").Value = Time()
rstclockedhours.Update
End If
End Sub
My Problem.....
1. As you can see I can not figure out how to search for a passkey and then come up with the name that goes with it....
2.That snippet does make a generic record,,, but I don't know how to make it error proof to not make a double login , throw up a msg saying you are already logged in if thats the case....
3. And how to edit the log out version to edit a current record instead of making a new one, and throwing up a msg that you are not logged in so you cant log out ect
I have 2 tables,
table 1 is [Employees] with Fields [Name] and [Passcode]
table 2 is [Clockedhours] with fields [Employee] , [Date of Work] , [Start Time] , [End Time]
I have one Form with 2 buttons Login and Logout, when pressed brings up an Input box asking for passcode for the user to login.
What I want it to do is search [Employees] for the passcode, if it matches a code then i want it to use that [Employee] to make a record in [Clockedhours] if it is a login, or if it is a log out i want it to find the record based on the employee and edit it to add the [end time].
What I got so far....
Private Sub Command2_Click()
Dim passkeybox As String
passkeytitle = "Enter passkey to clock in....."
passkeymsg = "Passkey Box"
passkeybox = InputBox(passkeytitle, passkeymsg)
If passkeybox = "12345678" Then
Dim dbtimecard As DAO.Database
Dim rstclockedhours As DAO.Recordset
Set dbtimecard = CurrentDb
Set rstclockedhours = dbtimecard.OpenRecordset("clockedhours")
rstclockedhours.AddNew
rstclockedhours("Employee").Value = "Testname"
rstclockedhours("Date of Work").Value = Date
rstclockedhours("Start Time").Value = Time()
rstclockedhours.Update
End If
End Sub
My Problem.....
1. As you can see I can not figure out how to search for a passkey and then come up with the name that goes with it....
2.That snippet does make a generic record,,, but I don't know how to make it error proof to not make a double login , throw up a msg saying you are already logged in if thats the case....
3. And how to edit the log out version to edit a current record instead of making a new one, and throwing up a msg that you are not logged in so you cant log out ect