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

punch clock time wont save in the listview

$
0
0
hello
i have a problem
i created a form that users punches the clock when they come to work and exit when they finish there job
i have another form that pulls the user name from another form in the database with a combobox
now when i try to punch in a user i get error "not in the item collection" and some other errors
anyway i post the code here
this is the table name in the the database Time,TimerID,TimeName,TimerIN,TimerOut
this is the form load
Code:

Private Sub Form_Load()
  Me.WindowState = 2
    Set RS = CN.Execute("SELECT * FROM Users")
    While Not RS.EOF
   
        CmbName.AddItem RS!UserName
        CmbName.ItemData(CmbName.NewIndex) = RS!UserID
        RS.MoveNext
       
        Wend
       
ListRTL LsVw


End Sub

now this is the code form the save (punchclockin)
Code:

Private Sub BttnIN_Click()
      Set Itm = LsVw.ListItems.Add(, "U" & RS!TimerID, RS!UserName, , "time")
        Itm.SubItems(1) = RS!UserPass
        Set RsTtl = CN.Execute("SELECT UserName, LogName, MAX(LogIN) AS LastIN, MAX(TimerOut) AS TimerOut AS LastOut FROM Users, Logs " & _
            "GROUP BY TimerName, LogName HAVING TimerName= '" & RS!LogName& "' AND TimerName=LogID")
        Itm.SubItems(2) = IIf(RsTtl.EOF Or IsNull(RsTtl!TimerIN), "", RsTtl!TimerIN)
        Itm.SubItems(3) = IIf(RsTtl.EOF Or IsNull(RsTtl!TimerOut), "", RsTtl!TimerOut)
End Sub

now this is the code to exit work and save the last logout
Code:

Private Sub BttnExit_Click()
  If MsgBox("did you finish to work?", vbInformation + vbYesNo + vbDefaultButton2, "Exit") = vbNo Then
           
           
        Else
            CN.Execute "UPDATE Time SET " & _
                "TimerOut= '" & Format(Now, "dddd, dd  mmmm  yyyy - HH:MM:SS") & "' " & _
                "WHERE TimerID= " & ULog
           
        End If
End Sub

tnx for the help amigos

Viewing all articles
Browse latest Browse all 21237

Trending Articles



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