Sum of Query

snagrat

Registered User.
Local time
Today, 03:36
Joined
Apr 2, 2002
Messages
61
I have a query on one of my forms that calculates the sum of all the records in one of tables. The table is also getting added to, but I can't seem to be able to get my query to recalculate the correct sum on my form.

Can anyone help?

Cheers
 
When is the query running? Do you need to force it to run again? For example, if it runs in the form's Open event, it would not include any rows added/deleted after the form was opened.
 
It needs to run every time one of my command buttons are clicked

I tried requery but that does seem to work with queries. How is it possible to get it to run and calculate the new values after my command buton is clicked?
 
I currently have the following code on my command button

Private Sub cmdDelete_Click()

On Error GoTo Err_cmdDelete_Click

With DoCmd
.SetWarnings False
.OpenQuery "qryDelete", acViewNormal, acEdit
.SetWarnings True
End With

txtDiscount.Requery
lstProducts.Requery
txtNetPrice.Requery
txtTotalPrice.Requery
Me.Requery

Exit_cmdDelete_Click:
Exit Sub

Err_cmdDelete_Click:
MsgBox Error$
Resume Exit_cmdDelete_Click

End Sub

However this does not make the query run again. So I need an extra line of code so that it forces the query to run again.

Hard to explain but I hope you understand what I mean
 
Me.Requery will requery the form. That is all you should need.
 

Users who are viewing this thread

Back
Top Bottom