Forms SQL Query Question

G

Gator

I have a form that displays in tabular form a table. The form footer
contains a textbox that sums the 'amount' field. I want to add another
textbox that displays the sum of the 'amount' of a query of records where
another field is queried.

For example. =SUM(Amount) WHERE City LIKE 'B%'

I can't get this to work....is there something i'm doing wrong?

Many Thx
 
B

Bob Quintal

I have a form that displays in tabular form a table. The form
footer contains a textbox that sums the 'amount' field. I want to
add another textbox that displays the sum of the 'amount' of a
query of records where another field is queried.

For example. =SUM(Amount) WHERE City LIKE 'B%'

I can't get this to work....is there something i'm doing wrong?

Many Thx

You can only use the sum() function in a totals query or on all the
records in the form. If you need to obtain a filtered version of a
sum, use the dSum() function unstead. It accepts 3 parameters,
the field to sum, the name of the table or query which contains the
field, and the Where clause less the WQhere keyword.
= dsum("amount","queryName","City like 'B*'")

Note that the % wildcard is used in some SQL dialects, in others,
including Access, the equivalent is the *
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top