DCount Function and Variable

  • Thread starter Thread starter Jonas
  • Start date Start date
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.
 
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
 
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

Similar Threads

Access Dcount function in access 0
Access Dcount (multiple criteria) 3
Dcount operation 2
DCOUNT 5
Syntax for DCount Code 4
Access MS Access DCount function problem 0
DCount alwaysreturning 1 0
Help correcting syntax for DCOUNT 1

Back
Top