Dsum???

Nirious

Registered User.
Local time
Today, 18:17
Joined
Jul 31, 2004
Messages
106
I have a form which contains a subform. The subform is based on a table named: "Results"

I have a textbox on my mainform which needs to show the sum of all the "Amount"s in the subform that have "type = 'Order'"


So I tried the controlsource of the textbox and I'mpretty sure that it can be done with DSUM. BUt I never used it before so some help is welcome.

Nirious
 
As a simple guideline, DSUM builds a query that is equivalent to

SELECT Sum([Field]) FROM Table WHERE selection criteria;

And you write it as

DSUM( "[Field]", "Table", "selection criteria" )

Doesn't take much to see what it must do, eh?

The Help Files will give you some examples.
 
I don't know why but I always get #Error

can you type it for me please, so I can just copy paste it.
This is the sql statement

SELECT Sum(Amount) FROM Results WHERE Type = 'Order'
 
SELECT Sum(Amount) FROM Results WHERE Type = 'Order'

SHOULD be

Dsum( "[Amount]", "Results", "Type = 'Order'" )

Unless you have a references error somewhere.

But let me add that TYPE is a reserved word and you might be getting fouled up in mis-use of reserved words.
 
Didn't work. Type is prolly the problem as you said so I gave up on this and just did it the hard way. You know
Making a query, making a form based on that query, putting it in a subform and requery it from time to time. Djees and all that for a stupid total :cool:
 

Users who are viewing this thread

Back
Top Bottom