VBA Dsum

jimmy1981

Registered User.
Local time
Today, 09:31
Joined
Mar 1, 2011
Messages
16
I have the following code to try and calculate a total amount from a table:

Code:
Dim LTotal As Currency
LTotal = DSum("Total_Price", "Recipe_Ingredients", RecipeId)
Forms![Recipes1]![Text45] = LTotal

Yet when it runs it appears to be calculating the total of all the table rather than for a specific RecipeId.

What am I doing wrong?
 
The last part of the Dsum function requires a boolean.
Code:
DSum("Total_Price", "Recipe_Ingredients", "Id =" & RecipeId)
A boolean 0 means False. Everything else is true. That's why you get the total sum.

HTH:D
 
Thanks Guus, works a treat.
 

Users who are viewing this thread

Back
Top Bottom