473,396 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Variable (Function) as Criteria still not working...

I'm trying to use a variable (as string) within criteria for DCount. I searched and found that you can't, and that instead I would need to write a one line function to return that same value.

1) Is this true?

2) Regardless, what would the final line look like? I would imagine something like this?:

Calculate = DCount("[expr]", "domain", "[expr] = GetValue()")
???

Clearly this doesn't work:
Calculate = DCount("[expr]", "domain", "[expr] = stringVariable")

Thanks in advance for your help! Oh and I sincerely encourage multiple responses to the same noob question. Thank you so much.
Oct 17 '06 #1
4 3089
MMcCarthy
14,534 Expert Mod 8TB
This will work:

Calculate = DCount("[expr]", "domain", "[expr]=" & stringVariable)



I'm trying to use a variable (as string) within criteria for DCount. I searched and found that you can't, and that instead I would need to write a one line function to return that same value.

1) Is this true?

2) Regardless, what would the final line look like? I would imagine something like this?:

Calculate = DCount("[expr]", "domain", "[expr] = GetValue()")
???

Clearly this doesn't work:
Calculate = DCount("[expr]", "domain", "[expr] = stringVariable")

Thanks in advance for your help! Oh and I sincerely encourage multiple responses to the same noob question. Thank you so much.
Oct 17 '06 #2
i've tried that too...

It doesn't work. I don't understand that line either. arg!

ok something more helpful:

Private Function Calculate(ethnic As String, status As String) As Integer
Calculate = DCount("[ethnicity]", status, "[Ethnicity] =" & ethnic)

is what I have. i MsgBox out both ethnic and status to find that both are read correctly. Why won't this work!?

please and thank you
Oct 17 '06 #3
MMcCarthy
14,534 Expert Mod 8TB
Sorry I forgot it was a string, it needs single quotes.

Calculate = DCount("[ethnicity]", status, "[Ethnicity] ='" & ethnic) & "'"



i've tried that too...

It doesn't work. I don't understand that line either. arg!

ok something more helpful:

Private Function Calculate(ethnic As String, status As String) As Integer
Calculate = DCount("[ethnicity]", status, "[Ethnicity] =" & ethnic)

is what I have. i MsgBox out both ethnic and status to find that both are read correctly. Why won't this work!?

please and thank you
Oct 17 '06 #4
For clarification should anyone in the future find this, he's absolutely right and genius, but even the best of us have some typos.

Calculate = DCount("[ethnicity]", status, "[ethnicity] ='" & ethnic & "'")

worked perfectly.

Thank you so much!
Oct 17 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: serge calderara | last post by:
Dear all, I am populating a treeview control with an XML file. I need to skip duplicate node entry from XML file in treeview if exit For that I ma using the following line of code : If...
4
by: KL | last post by:
I have the following function: void fillvaluecheck (int valuecheck, int size){ for (int m = 0; m < size; m++){ cout << valuecheck << endl; valuecheck = 0; cout << valuecheck << endl; }...
1
by: Daniel Chartier | last post by:
Hello. I have a question concerning variable criteria for queries and reading forms. Let's say that I have a table with 2 fields and 10 records. One of the fields can have two different...
3
by: Mike Ridley | last post by:
I am running Access 97 on a Windows XP system. I run a query on an ODBC connected file that selects records for a particular date. I can hard code the selection criteria eg #25/03/2004# or get it...
2
by: K B | last post by:
I'm sorry to post OT here but I was hoping that someone could help me. I use Visual Studio 2005 and suddenly my Find feature has completely stopped working. When I select it, the screen flickers...
3
by: not_a_commie | last post by:
Does MS have an official C# variable/function/codingstyle standard that is available on the internet? What standard do they use for their internal coding? Mind posting a link? Thanks.
33
by: buss123 | last post by:
Hi all, combo box script code was working in IE perfectly with all modes but OnChange event was not working in FireFox(editable mode, if we select valuese that combo box values r...
2
jmoudy77
by: jmoudy77 | last post by:
Hi, I'm trying to use a variable "FirstSemi" as the second criteria in a DSum function. The DSum function is used in the same Form_Load function that the variable was declared. I keep getting an...
1
by: manmadhan | last post by:
i refer lots of website for "timediff mysql function not working in gridview" , its working mysql tool but in asp.net gridview its not working.... please any one help me for this problem
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.