DSum with Multiple Queries (1 Viewer)

unclefink

Registered User.
Local time
Yesterday, 18:48
Joined
May 7, 2012
Messages
184
Subject should say DSUM with multiple criteria, sorry.

I'm having a hard time getting this criteria to work for me.

I have a table called Extractsales that contains the following Fields:

RecordID
SalesDate
ItemSold - This is referenced to the id of an item in another table
NumberSold
TotalAmount

I'm trying to create a query giving me the total number of a specific item that was sold during current year.

I'm using Dsum syntax as followed:

Test: DSum("[Numbersold]","ExtractSales","[itemsold]=1" And "Year( [ExtractSales]![SalesDate]=Year(Date()")

When I run the query, its giving me a count of 19 which is actually the total items sold which includes item number 2. Of the 19 only 15 of those are for "item 1".

Can anyone help me. I just started figuring out Dsum syntax last night and now i'm obsessed with getting this right!

Thanks a bunch in advance.
 

unclefink

Registered User.
Local time
Yesterday, 18:48
Joined
May 7, 2012
Messages
184
Re: DSum with Multiple criteria

The query seems to be working, its just not adding both criteria.

As for the reference to multiple queries, i'm only using 1 query NOT multiple, I overlooked that reference on my initial creating this string.
 

unclefink

Registered User.
Local time
Yesterday, 18:48
Joined
May 7, 2012
Messages
184
if it helps at all, here is a snippet of the data table i'm trying to "dsum".

See attached.
 

Attachments

  • Capturetbl.PNG
    Capturetbl.PNG
    11.7 KB · Views: 206

plog

Banishment Pending
Local time
Yesterday, 20:48
Joined
May 11, 2011
Messages
11,645
Again, DSums shouldn't be in queries. Your methodology (nevermind your syntax) is incorrect.

You need to build an aggregate query to get this data using the SUM keyword of SQL. Not using the DSum function of Access.
 

Users who are viewing this thread

Top Bottom