DSum Query using Date

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created a database which tracks inventory and calculates and monitors
turnover. In my query I have 4 columns that are put in by the user in a form
linked to a "Transactions" table: Issues, Receipts, ProeprtyNumber and
TransactionDate. I created a field (InvLvl) which is supposed to calculate
the current inventory level for each property. Here is the formula for that
cell:

InvLvl: DSum("[Issues]+[Receipts]","Transactions","PropertyNumber=" &
[PropertyNumber] & " AND TransactionDate<= #" & [TransactionDate] & "#")

This query almost always works, but in a few cases, it will ignore the first
transaction entered and only use the other transactions when calculating the
inventory level, throwing off all of my numbers. Is there a reason this is
happening that I am not seeing? If it helps, the "Issues" field must always
be negative, while the "Receipts" field is always positive. Also, I'm using
Access 2002.
 
Well, could it be that Issues or Receipts is a null value in those cases?

If either one is a null, then the calculation of issues + receipts is going to
be null.

I'm not sure this will work inside the Dsum, but you might try

DSum("Nz(Issues,0) + Nz(Receipts,0)",...)
 
That was it. The default value is set to 0, it accidently got erased in
those cases.

Thanks!

John Spencer said:
Well, could it be that Issues or Receipts is a null value in those cases?

If either one is a null, then the calculation of issues + receipts is going to
be null.

I'm not sure this will work inside the Dsum, but you might try

DSum("Nz(Issues,0) + Nz(Receipts,0)",...)
I have created a database which tracks inventory and calculates and monitors
turnover. In my query I have 4 columns that are put in by the user in a form
linked to a "Transactions" table: Issues, Receipts, ProeprtyNumber and
TransactionDate. I created a field (InvLvl) which is supposed to calculate
the current inventory level for each property. Here is the formula for that
cell:

InvLvl: DSum("[Issues]+[Receipts]","Transactions","PropertyNumber=" &
[PropertyNumber] & " AND TransactionDate<= #" & [TransactionDate] & "#")

This query almost always works, but in a few cases, it will ignore the first
transaction entered and only use the other transactions when calculating the
inventory level, throwing off all of my numbers. Is there a reason this is
happening that I am not seeing? If it helps, the "Issues" field must always
be negative, while the "Receipts" field is always positive. Also, I'm using
Access 2002.
 

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

Back
Top