Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21127

[RESOLVED] time in time out

$
0
0
i have form for employees when they come to work and punch in and out
so far i managed to code the punch in clock but not the punch out clock
cant figure it out i tried something but i get a error syntax error in update statment
i need some help
this is the code:
Punch IN Clock
Code:

Private Sub BttnIN_Click()
If CmbName.ListIndex = -1 Then
MsgBox "choose an employee", vbInformation
CmbName.SetFocus
Exit Sub
End If


   
    If NewRec 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$(CmbName.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")
          CmbName.ListIndex = -1
          ChkRepeat.Value = 0
         
            Exit Sub
        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
           
            PickDate.Value = Format(.text, "dd/mm/yyyy")
            Txt(1).text = .SubItems(1)
            CmbName.text = Trim$(.SubItems(2))
            Txt(2).text = .SubItems(3)
         
         
        End With
    End If
    Unload Me

this is the Punch Out Clock
Code:

Private Sub BttnOUT_Click()
If MsgBox("punchout?", vbInformation + vbYesNo + vbDefaultButton2) Then
 With Frmtime.LsVw.SelectedItem
        strSQL = "UPDATE Enterwork SET"
        strSQL = strSQL & "EnterOut = #" & MyDate(PickDate.Value) & "#,"
        strSQL = strSQL & "EnterRemarks = '" & Text1.text & "'"
        strSQL = strSQL & " WHERE EnterID = " & Frmtime.LsVw.SelectedItem.Tag
        MsgBox strSQL
        CN.Execute strSQL
        MsgBox "You are now Punched Out."
         
          End With
End If
End Sub

Code:

table name:Enterwork
values
EnterID
EnterDate
EnterDay
EnterName
EnterIN
EnterOut
EnterRemarks

if any more information is needed i will add here
regards salsa31

Viewing all articles
Browse latest Browse all 21127

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>