Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using variable in Dcount 1

Status
Not open for further replies.

Du2good

Technical User
May 9, 2005
41
US
I'd like to be able to replace [4d] with the variable DeclineCd in this DCount but havent got it yet. Maybe its not possible? What should I do different. Thanks!!

This works:
Code:
Closed = DCount("[Account #]", "tblEOMRpt", " [4D] =  -1 AND [Rep] = '" & REP & "' ")

This doesnt work and it returns zero:
Code:
Closed = DCount("[Account #]", "tblEOMRpt", "' " & DeclineCd & "' " = -1 And [REP] = "' & Rep & '")
 
Try removing the quotes:
Code:
Closed = DCount("[Account #]", "tblEOMRpt", DeclineCd & " = -1 And [REP] = "' & Rep & '")

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
OK traingamer, thank you for your suggestion but it gives the message:

Complile error; Expected:list separator or )

And the first single quote following [Rep] is highlighted by the debugger. Removing the single and adding or switching with double qoutes gives only errors.

Before posting I tried adding/removing single and double quotes for way too many hours and am about ready to give up on this. But a soulution would be appreciated. Thank you
 
Is "DeclineCD" a field name?

Closed = DCount("[Account #]", "tblEOMRpt", "[DeclineCd] = -1 And [REP] = '" & Rep & "'")

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
And what about this ?[tt]
Closed = DCount("[Account #]", "tblEOMRpt", "[" & DeclineCd & "] = -1 And [REP] = '" & Rep & "'")[/tt]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV, You got it exactly!![2thumbsup]
I was hoping you would post on this, Thank you very much!!

GingerR, DeclineCD is a variable holding various field names.

Thank you all. This is a great site.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top