i'm trying to check before a user punches in his name and his password
i played with it and every time a different error shows up. end if without else, variable not define, and so on
or it enters without checking the user & pass a real mess
this is the code:
and the code that is marked in red dosnt even show the timeout and the remarks in the listview(it shows only in the database table) when a
user Punches Out
i played with it and every time a different error shows up. end if without else, variable not define, and so on
or it enters without checking the user & pass a real mess
this is the code:
Code:
If TxtName.text = "" Then
MsgBox "name is blank", vbExclamation
TxtName.SetFocus
Exit Sub
End If
If TxtPass.text = "" Then
MsgBox "password is blank", vbExclamation
TxtPass.SetFocus
Exit Sub
End If
If NewRec Then
Set rs = CN.Execute("SELECT UserName, UserPass FROM Users WHERE UserName= '" & RplS(Txt(0).text) & "'")
If rs.EOF Then
MsgBox "this name doesnt exists in the database", vbExclamation, ""
TxtName.text = ""
TxtPass.text = ""
TxtName.SetFocus
ElseIf TxtPass.text <> rs!UserPass Then
MsgBox "the password for this user you entered is wrong", vbInformation, ""
TxtPass.text = ""
TxtPass.SetFocus
Else
Dim intResponse As Integer
intResponse = MsgBox("Punch the Clock In?", _
vbYesNo + vbInformation, _
"Shift In")
If intResponse = vbYes Then
Dim NewID As Long
NewID = NextID("EnterID", "Enterwork")
Dim strSQL As String
strSQL = "INSERT INTO Enterwork "
strSQL = strSQL & "(EnterID, EnterDate, EnterDay, EnterName, EnterIN)"
strSQL = strSQL & "VALUES("
strSQL = strSQL & NewID & ","
strSQL = strSQL & "#" & MyDate(PickDate.Value) & "#,"
strSQL = strSQL & "'" & Txt(1).text & "',"
strSQL = strSQL & "'" & CmbName.text & "',"
strSQL = strSQL & "'" & Txt(2).text & "'"
strSQL = strSQL & ")"
CN.Execute strSQL
Set itm = Frmtime.LsVw.ListItems.Add(, , Frmtime.LsVw.ListItems.Count + 1, , "logkey")
itm.Tag = NewID
itm.SubItems(1) = Replace$(PickDate.Value, ",", ".")
itm.SubItems(2) = Replace$(Txt(1).text, ",", ".")
itm.SubItems(3) = Replace$(TxtName.text, ",", ".")
itm.SubItems(4) = Replace$(Txt(2).text, ",", ".")
If ChkRepeat.Value Then
PickDate.Value = Now
Txt(1).text = Format(Now, "dddd")
Txt(2).text = Format(Now, "HH:MM:SS")
TxtName.text = ""
ChkRepeat.Value = 0
Exit Sub
End If
End If
Else
With Frmtime.LsVw.SelectedItem
strSQL = "UPDATE Enterwork SET "
strSQL = strSQL & "EnterDate = #" & MyDate(PickDate.Value) & "#,"
strSQL = strSQL & "EnterDay = '" & Txt(1).text & "',"
strSQL = strSQL & "EnterName = '" & CmbName.text & "',"
strSQL = strSQL & "EnterIN = '" & Txt(2).text & "'"
strSQL = strSQL & " WHERE EnterID = " & .Tag
CN.Execute strSQL
Set itm = Frmtime.LsVw.ListItems.Add(, , Frmtime.LsVw.ListItems.Count + 1, , "logkey")
itm.Tag = NewID
PickDate.Value = Format(.text, "dd/mm/yyyy")
Txt(1).text = .SubItems(1)
TxtName.text = .SubItems(2)
Txt(2).text = .SubItems(3)
End With
End If
End If
Unload Me
Code:
Dim intResponse As Integer
intResponse = MsgBox("Punch clock out", _
vbYesNo + vbInformation, _
"Punch Out")
If intResponse = vbYes Then
With Frmtime.LsVw.SelectedItem
strSQL = "UPDATE Enterwork SET "
strSQL = strSQL & "EnterOut = #" & MyDate(PickDate.Value) & "#,"
strSQL = strSQL & "EnterRemarks = '" & Txt(0).text & "'"
strSQL = strSQL & " WHERE EnterID = " & Frmtime.LsVw.SelectedItem.Tag
CN.Execute strSQL
End With
End If
Unload Me
user Punches Out