guys i am having some trouble here, please help me. I need it badly. What happens is when i ckick on the log in button, the button must first verify the date, then the password and username, if the date doesnt exist on the user's database, he should be logged in. But if the date already exist, he must wait for until the next day to log in again. but it is not working properly please help here is my code:
Private Sub Command3_Click()
Dim cnuser As New ADODB.connection
Dim rsuser As New ADODB.recordset
Dim rstimekeeping As New ADODB.recordset
'Dim rsdate As New ADODB.recordset
Call connection(cnuser, App.Path & "\JOCPAY.mdb", "engman")
Call recordset(rsuser, cnuser, "SELECT * FROM UserAccount")
If recfound(rsuser, "emp_id", Text1.Text) = False Then
MsgBox "Invalid Username.", vbExclamation, "JOC Marketing"
Text1.SetFocus
Call hlfocus(Text1)
Else
If password = Text2.Text Then
If rstimekeeping.State = adStateOpen Then rstimekeeping.Close
rstimekeeping.Open "select * from time_info where date_now = " & FormatDateTime(Now, vbShortDate) & " and emp_id = '" & Text1.Text & "'", cnuser, adOpenStatic, adLockOptimistic
'rsdate.Open "select * from Paygen", cnuser, adOpenStatic, adLockOptimistic
'If rstimekeeping("emp_id").Value <> Text1.Text Then
rstimekeeping.Requery
With rstimekeeping
If rstimekeeping("date_now").Value <> FormatDateTime(Now, vbShortDate) Then
.AddNew
.Fields!emp_id = Text1.Text
.Fields!time_in = Time
.Fields!date_now = Date
.Update
MsgBox "Successfully logged-in.", vbInformation, "JOC Marketing"
'rstimekeeping("date_now").Value = Date
Else
If rstimekeeping("time_in").Value = "" Then
.AddNew
.Fields!emp_id = Text1.Text
.Fields!time_in = Time
.Fields!date_now = Date
.Update
MsgBox "Successfully logged-in.", vbInformation, "JOC Marketing"
Else
If rstimekeeping("time_in").Value <> "" Then
MsgBox "You have already logged-in", vbExclamation, "JOC Marketing"
Else
End If
End If
End If
Call empOper
End With
Call viewuser
Else
MsgBox "Invalid Password.", vbExclamation, "JOC Marketing"
Call clearLBL
End If
Text1.SetFocus
Command2.Value = True
Call empdLoad
End If
Set cnuser = Nothing
Set rsuser = Nothing
Set rstimekeeping = Nothing
'Set rsdate = Nothing
End Sub