Results 1 to 23 of 23

Thread: [RESOLVED] How add a running total in a database

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2006
    Posts
    449

    Resolved [RESOLVED] How add a running total in a database

    I hope the title is not too confusing. I did not know exactly how to word what I need.

    In my program, when a person receives overtime, the number of hours is recorded and saved into the database. This part is fine.

    So, for example, when John Doe works 6 hours of OT, then it is added to the database.

    Now, when the person in charge of OT starts the program again, then John Doe should have 6 hours added to his total hours and it is displayed in the listview.

    My problem is, is that I dont know how to do the second part.

    Here is the code for adding the person info receiving OT hours:

    vb Code:
    1. Private Sub cmdSubmit_Click()
    2.     Dim strSQL As String
    3.     Dim blnTransOpen As Boolean
    4.     Dim ConnectionLiving As Boolean
    5.    
    6.    
    7.             'On Error GoTo ErrHandler
    8.    
    9.             blnTransOpen = False
    10.             ConnectionLiving = False
    11.    
    12.             Call openConn
    13.    
    14.             ConnectionLiving = True
    15.             dbconn.BeginTrans
    16.             blnTransOpen = True
    17.    
    18.             dbconn.Execute "INSERT INTO Event(FDID,Event_Name,Event_Hours,Time_Of_Event,Date_Of_Event,Time_Called, " _
    19.             & "Date_Called,HoursWorked,Left_Message) Values('" & txtFDID.Text & "', " _
    20.             & " '" & txtVenue.Text & "','" & txtHoursNeeded.Text & "','" & txtVenueTime.Text & "','" & txtVenueDate.Text & "', " _
    21.             & " '" & txtTimeCalled.Text & "','" & txtDate.Text & "','" & txtHoursWorked.Text & "','" & txtLeftMessage.Text & "')"
    22.            
    23.  
    24.            
    25.             dbconn.CommitTrans
    26.             blnTransOpen = False
    27.             'DBCon.Close
    28.             ConnectionLiving = False
    29.            
    30.            
    31. '            Call ClearTB
    32. End Sub

    For example: lets say John Doe currently has worked 25 hours of OT and now he has worked 6 more hours.

    So, now his total should be 31 hours. So, how is this entered into the database?

    I hope I am making sense.
    Last edited by cfd33; Apr 11th, 2010 at 10:58 PM. Reason: Title not clear.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width