Option Compare Database
Function Copy_of_Update_Petty_Cash_Balances_One_Day()
On Error GoTo Copy_of_Update_Petty_Cash_Balances_One_Day_Err
DoCmd.SetWarnings False
Dim i As Integer
Dim c As Integer
Dim db As DAO.Database
Dim rs As DAO.Recordset
'DoCmd.OpenQuery "Identify_PCBal_NoFlag_Records", acViewNormal, acEdit
'Set rs = db.OpenRecordset(identify_PCBal_NoFlag_Records, acViewNormal,
acEdit)
Set db = Application.CurrentDb
Set qy = db.CreateQueryDef("", "SELECT
count(Tbl_Petty_Cash_Balances.Flag)as c FROM Tbl_Petty_Cash_Balances WHERE
Tbl_Petty_Cash_Balances.Flag=false;")
Set rs = qy.OpenRecordset
'rs.Edit
'Set c = rs.Fields(0)
MsgBox c, vbOKOnly, "value of"
If c > 0 Then
For i = 0 To c
DoCmd.OpenQuery "Create_Last_Balance", acViewNormal, acEdit
DoCmd.OpenQuery "Create_Next_Balance", acViewNormal, acEdit
DoCmd.OpenQuery "Update_Last_Balance_Primary_Key", acViewNormal,
acEdit
DoCmd.OpenQuery "Update_Petty_Cash_Balances_Next_Day", acViewNormal,
acEdit
Beep
MsgBox "Updated one day", vbOKOnly, "Running Balance for Petty Cash"
Next i
End If
Copy_of_Update_Petty_Cash_Balances_One_Day_Exit:
Exit Function
Copy_of_Update_Petty_Cash_Balances_One_Day_Err:
MsgBox Error$
Resume Copy_of_Update_Petty_Cash_Balances_One_Day_Exit
End Function
Stefan,
Could you help me up to line of MsgBox c, vbOKOnly, "value of", to store
count value in c. Thank you very much.
Stefan Hoffmann said:
hi Jennifer,
the catch is TOTAL itself needs to be included as a denominate for total.
First of all, generate a row total and calculate it in the after update
event:
UPDATE
SET [row_total] = [col1] + [col2]
Then you need a candidate key to order your data, a autoincrement value
would do it:
UPDATE
SET [running_total] = DSum("[row_total]","
", "ID < " & [ID])
mfG
--> stefan <--