473,395 Members | 1,456 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,395 software developers and data experts.

DCount Using Report Textbox as Criteria

I did a search but couldn't find a question similar to mine. I need to count the values in a textbox on a report and have the count subtotal in a group footer. But I need three different counts on the same textbox because there are three possible values and I need a count on each. I can't just do a simple DCount on the table and manually define the criteria because there are many different groups that will need the counts for only that group. Maybe I'm going about this all wrong and shouldn't use DCount at all. But here's what I've got so far:

=DCount("[Field1]","Table","[Field2] = 'Value1' AND [Field3] = '«Expr» [Textbox]' ")

[Textbox] is the field on the report that contains the value of the current group that is being subtotaled. But I get no results. I either get an #Error or a 0 (yes, there are matching values in the table).

Is there a way to use a report variable as criteria or is there a better way to calculate the counts?
Jun 22 '07 #1
3 4764
puppydogbuddy
1,923 Expert 1GB
I did a search but couldn't find a question similar to mine. I need to count the values in a textbox on a report and have the count subtotal in a group footer. But I need three different counts on the same textbox because there are three possible values and I need a count on each. I can't just do a simple DCount on the table and manually define the criteria because there are many different groups that will need the counts for only that group. Maybe I'm going about this all wrong and shouldn't use DCount at all. But here's what I've got so far:

=DCount("[Field1]","Table","[Field2] = 'Value1' AND [Field3] = '«Expr» [Textbox]' ")

[Textbox] is the field on the report that contains the value of the current group that is being subtotaled. But I get no results. I either get an #Error or a 0 (yes, there are matching values in the table).

Is there a way to use a report variable as criteria or is there a better way to calculate the counts?
Not sure what you are trying to do, but try this:

=IIf(YourTextbox = Value1, Count([Field1]), IIf(YourTextbox = Value2, Count([Field2]), Count([Field3])))

The above assumes you have 3 columns, but only want the count of the column that is referenced in the textbox. Otherwise, if you want counts of all 3 columns, you need 3 textboxes in the footer, each with a count.

= Count([Field1])
= Count([Field2])
= Count([Field3])
Jun 22 '07 #2
Not sure what you are trying to do, but try this:

=IIf(YourTextbox = Value1, Count([Field1]), IIf(YourTextbox = Value2, Count([Field2]), Count([Field3])))

The above assumes you have 3 columns, but only want the count of the column that is referenced in the textbox. Otherwise, if you want counts of all 3 columns, you need 3 textboxes in the footer, each with a count.

= Count([Field1])
= Count([Field2])
= Count([Field3])
I only have one column, that's the problem. I can do three columns but then I'd have to do a lot of extra coding. And if I used your formula, I'd have to change the report everytime a new value was entered for the textbox :/
Jun 22 '07 #3
puppydogbuddy
1,923 Expert 1GB
I only have one column, that's the problem. I can do three columns but then I'd have to do a lot of extra coding.
If you only have one column, but you want a count for each group, all you need to do is place a textbox in the <<<group footer>>> as follows:

= Count([YourField])

If you don't have a group footer, then invoke the sorting/grouping tool and select the field that you want to group on and provide the info requested in the dialog box. If you have a group footer that totals the Sum, all you have to do is place another textbox right below it with the above expression.
Jun 22 '07 #4

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

Similar topics

7
by: jdph40 | last post by:
I posted this problem previously and received excellent help from Wayne Morgan. However, I still have an unanswered question. My form (frmVacationWeeks) is opened from the OnClick event of a...
1
by: Simon Matthews | last post by:
Hope someone can help an Access beginner! I've just started keeping my surgical logbook on access and it's a simple flat-file affair. I have created several queries that will list cases...
1
by: Megan | last post by:
Hi Everybody- I've been reading some of the posts about DCOUNT, and I haven't yet found an answer; so, I'm posting this question. I have a report that I'm trying to use DCOUNT on to compute...
6
by: Mike Conklin | last post by:
This one really has me going. Probably something silly. I'm using dcount for a report to determine the number of different types of tests proctored in a semester. My report is based on a...
1
by: Rinee | last post by:
Hi, I have a database of a bunch of contractors who have signed a safety agreement with us, their contact info, their insurance info, etc. Each was assigned an ID number as the main key. Each...
2
by: ChasW | last post by:
Greetings, I have a form that uses a query as its record source. In the form I have a text box that uses this as its control source: =DCount("", "qry_Search_by_Name") The DCount function...
7
by: Michael R | last post by:
Good afternoon. I'm stucked in composing the syntax for DCount expression in a select query. The query qryCustomers has CustomerID field, the DCount function uses tblLoans with LoanDate and Id fields...
36
by: bmyers | last post by:
Good afternoon, I am attempting to count only those records within a report, which is based on a query, where Status is equal to Closed. I have tried multiple variations of DCOUNT but am...
1
by: akirekab | last post by:
I am using DCount, but I am not able to find how to set simple multiple criteria. Here is sample of what i need. =DCount("PatientProfileID","qryFaceToFaceReason_EAP_VG","FaceToFaceReasonID=2"...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...

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.