Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem using DSum??

Status
Not open for further replies.

marlun

Programmer
Feb 7, 2003
70
0
0
SE
Hi!
I want to get a value in a textfield on a form using DSum.
When the form open I have an event procedure that sums up the value in a storage for each market. INow I have this line:

Forms!Ekonomi!Saldo = DSum("Antal*Lagervärde_avg", "tblLager",[ ])

The problem is that I dont know how to write the criteria.
In table A (tblLager) I have the amounts to sum. In table B I have the market each product belong to. What I need is a way to sum the totals in each marketgroup. Hope you understand what I mean.

Please help
 
It goes something like this:

Forms!Ekonomi!Saldo = DSum("[Antal*Lagervärde_avg]", "tblLager", "[Antal*Lagervärde_avg] = 'Fosters'")

Regards

Bill

 
Hi again, sorry I don't I understand what you mean. What is Fosters???
 
Only one of the most popular Australian Lagers in the UK.

Actually, in retrospect try:

Forms!Ekonomi!Saldo = DSum("[Antal*Lagervärde_avg]", "tblLager", "[FieldNameToLookup] = 'Criteria'")

Or another way if the Criteria is being selected in a Control:

Forms!Ekonomi!Saldo = DSum("[Antal*Lagervärde_avg]", "tblLager", "[FieldNameToLookup] = " & Forms!Ekonomi!ControlNameStatingCriteria)


If this doesn't work first time experiment with and without the 's (apostrophes) enclosing the criteria.

Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top