DCount Function and Variable

J

Jonas

I want to be able to use the DCount function with a variable. I have
tried a few different things but I can't find the right formula. Here
is what I have:

cntnumber = DCount("[TikSym]", "tblCurHold", "[SecIDauto] ='" _
& secidvar1 & "'")

If I replace secidvar with 1 and change the formatting, the Dcount
formula works. 1 is possible number for the variable secidvar1.

I can't see what I am doing wrong. Any help is appreciated.
 
U

UpRider

If secidvar1 is numeric, try

cntnumber = DCount("[TikSym]", "tblCurHold", "[SecIDauto] = " _
& "secidvar1")

If it's text,
cntnumber = DCount("[TikSym]", "tblCurHold", "[SecIDauto] = " _
& Chr$(39) & secidvar1 & Chr$(39))

UpRider
 
J

Jonas

If secidvar1 is numeric, try

cntnumber = DCount("[TikSym]", "tblCurHold", "[SecIDauto] = " _
& "secidvar1")

If it's text,
cntnumber = DCount("[TikSym]", "tblCurHold", "[SecIDauto] = " _
& Chr$(39) & secidvar1 & Chr$(39))

UpRider




I want to be able to use the DCount function with a variable. I have
tried a few different things but I can't find the right formula. Here
is what I have:
cntnumber = DCount("[TikSym]", "tblCurHold", "[SecIDauto] ='" _
& secidvar1 & "'")
If I replace secidvar with 1 and change the formatting, the Dcount
formula works. 1 is possible number for the variable secidvar1.
I can't see what I am doing wrong. Any help is appreciated.- Hide quoted text -

- Show quoted text -

I got the formula to work. I just took out the parentheses from
around the variable. Here is the formula:
cntnumber = DCount("[TikSym]", "tblCurHold", "[SecIDauto] = " _
& secidvar1)
 

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