Solved DSUM with multiple criteria....

TajikBoy

Member
Local time
Today, 08:44
Joined
Mar 4, 2011
Messages
83
Hi Guys,

Trying to sum fields based on a ID from a form, and a text field, fixed - my version is below - what am I doing wrong?

=DSum([total],[qrybudget],"[ProjectName] = " & [me].[ID] & " And ctrBudgetType = 'Seed'")

ProjectName is a number field, and ctrBudgetType is a text.....

Thanks in advance,
 
=DSum("total","qrybudget","[ProjectName] = " & [me].[ID] & " And ctrBudgetType = 'Seed'")
 
=DSum("total","qrybudget","[ProjectName] = " & [me].[ID] & " And ctrBudgetType = 'Seed'")
Thanks but no sugar yet...Filed comes up as #Name?
 
that's not a problem.
check each spelling if it does exists on qryBudget.
 
I can't see any misspelled field names, and query is working as it should be - Dsum should give total of 2 seeds, maybe one day ;)


query.png
output.png
 
maybe add square brackets.

=DSum("[total]","[qrybudget]","[ProjectName] = " & [me].[ID] & " And [ctrBudgetType] = 'Seed'")
 
maybe rename the Textbox to another name, ie, txtValue (by just prefixing with txt)
 
Instead of the Dsum can you just make an aggregate query
Group by project name, sum of total, where type = seed. Then link your query by project. If you want to only show seeds do an inner join, it you want all then do an outer join.
 
Put the criteria into a string variable and Debug.Print that to see what you produce.
 
Thanks guys, as I didn't get anywhere with multiple criteria, I built in the fixed element into the query and Dsum'ed with the projectName - now it works, not the ideal way but problem solved for now
 
Either you're typing/pasting it wrong, or your object names are misspelled, because the original response from Arnel is correct.
 

Users who are viewing this thread

Back
Top Bottom