DSum Formula Problem

J

Jonas

I'm hoping that somebody can help me out with a DSum formula
associated with a command button on a form. Here is what I have:

sumshares = DSum("[shares]", "tblUnfilledsubtable", [TradeIDauto] =
TradeID)

The current result is the sum of all of the shares in the field
"shares"

TradeIDauto is a field in "tblUnfilledsubtable"

TradeID is a string variable that contains the Trade ID from the
current form. I know that my code obtained the trade ID because I
can get it to show in a message box.

I know that the problem is the criteria section because if I enter an
ID that exists in tblUnfilledsubtable it works. Here is an example:

sumshares = DSum("[shares]", "tblUnfilledsubtable", "[TradeIDauto] =
17")

Any suggestions for dealing with variables in a DSum formula are much
appreciated.
 
J

Jonas

sumshares = DSum("[shares]", "tblUnfilledsubtable", "[TradeIDauto] = " &
TradeID)

(I suspect that the above will word-wrap: it should be all on one line)

Seehttp://www.mvps.org/access/general/gen0018.htmfor more details.

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no private e-mails, please)




I'm hoping that somebody can help me out with a DSum formula
associated with a command button on a form. Here is what I have:
sumshares = DSum("[shares]", "tblUnfilledsubtable", [TradeIDauto] =
TradeID)
The current result is the sum of all of the shares in the field
"shares"
TradeIDauto is a field in "tblUnfilledsubtable"
TradeID is a string variable that contains the Trade ID from the
current form. I know that my code obtained the trade ID because I
can get it to show in a message box.
I know that the problem is the criteria section because if I enter an
ID that exists in tblUnfilledsubtable it works. Here is an example:
sumshares = DSum("[shares]", "tblUnfilledsubtable", "[TradeIDauto] =
17")
Any suggestions for dealing with variables in a DSum formula are much
appreciated.- Hide quoted text -

- Show quoted text -

That worked. Thanks very much.
 

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