473,396 Members | 1,805 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.

Count Records In Code In Group Header

I have a sales report where the sales are grouped by district. The report is
based on a query with criteria for sales date to get the sales in any
specified date range. I have code in the Format event of the district group
header. How do I get the count of sales in the current district in the code
in the Format event of the district group header?

Thanks!

Melissa
Nov 13 '05 #1
3 3626
Try a DCount statement in a calculated textbox or in code.

Example:
DCount("*", "NameOfReportsRecordSource", "[GroupID]=" & Me.txtGroupID)

If the code is in a calculated textbox, leave out the "Me.". Also, this
assumes the value to be a number, if it is a text value, you'll have to
concatenate in quotes around it also.

Example:
DCount("*", "NameOfReportsRecordSource", "[GroupID]='" & Me.txtGroupID &
"'")
or
DCount("*", "NameOfReportsRecordSource", "[GroupID]=""" & Me.txtGroupID &
"""")

For this to work, you will need to place a textbox in the group header and
bind it to this field. You can set the Visible property of the textbox to No
or False if you don't need it to show for something else.

--
Wayne Morgan
Microsoft Access MVP
"Melissa" <mb****@earthlink.net> wrote in message
news:3B*****************@newsread2.news.atl.earthl ink.net...
I have a sales report where the sales are grouped by district. The report
is
based on a query with criteria for sales date to get the sales in any
specified date range. I have code in the Format event of the district
group
header. How do I get the count of sales in the current district in the
code
in the Format event of the district group header?

Thanks!

Melissa

Nov 13 '05 #2
Wayne,

Thank you for responding! I used the expression you suggested. My value is
text so I concatenated as you showed. When I run the code to use the DCount
value I get the message "You Entered An Expression That Has No Value". The
code is actually calling a function that uses the DCount expression. It
seemed to me the message was saying txtGroupID (my code uses DistrictID) has
no value when the function is called from the On Format event. Just out of
curiosity I added the following to the code:
MsgBox Reports!SalesReport!MyField

No matter which field I put in the above expression, I keep getting the same
message. So it seems that the SalesReport does not yet have any data when
the On Format event fires. This being the case, you suggestion is not going
to work to count the records. Any thoughts??

Melissa
"Wayne Morgan" <co***************************@hotmail.com> wrote in message
news:ll******************@newssvr33.news.prodigy.c om...
Try a DCount statement in a calculated textbox or in code.

Example:
DCount("*", "NameOfReportsRecordSource", "[GroupID]=" & Me.txtGroupID)

If the code is in a calculated textbox, leave out the "Me.". Also, this
assumes the value to be a number, if it is a text value, you'll have to
concatenate in quotes around it also.

Example:
DCount("*", "NameOfReportsRecordSource", "[GroupID]='" & Me.txtGroupID &
"'")
or
DCount("*", "NameOfReportsRecordSource", "[GroupID]=""" & Me.txtGroupID &
"""")

For this to work, you will need to place a textbox in the group header and
bind it to this field. You can set the Visible property of the textbox to No or False if you don't need it to show for something else.

--
Wayne Morgan
Microsoft Access MVP
"Melissa" <mb****@earthlink.net> wrote in message
news:3B*****************@newsread2.news.atl.earthl ink.net...
I have a sales report where the sales are grouped by district. The report
is
based on a query with criteria for sales date to get the sales in any
specified date range. I have code in the Format event of the district
group
header. How do I get the count of sales in the current district in the
code
in the Format event of the district group header?

Thanks!

Melissa


Nov 13 '05 #3
Thanks for your help, Wayne! I got your recommendation to work.

Melissa
"Wayne Morgan" <co***************************@hotmail.com> wrote in message
news:ll******************@newssvr33.news.prodigy.c om...
Try a DCount statement in a calculated textbox or in code.

Example:
DCount("*", "NameOfReportsRecordSource", "[GroupID]=" & Me.txtGroupID)

If the code is in a calculated textbox, leave out the "Me.". Also, this
assumes the value to be a number, if it is a text value, you'll have to
concatenate in quotes around it also.

Example:
DCount("*", "NameOfReportsRecordSource", "[GroupID]='" & Me.txtGroupID &
"'")
or
DCount("*", "NameOfReportsRecordSource", "[GroupID]=""" & Me.txtGroupID &
"""")

For this to work, you will need to place a textbox in the group header and
bind it to this field. You can set the Visible property of the textbox to No or False if you don't need it to show for something else.

--
Wayne Morgan
Microsoft Access MVP
"Melissa" <mb****@earthlink.net> wrote in message
news:3B*****************@newsread2.news.atl.earthl ink.net...
I have a sales report where the sales are grouped by district. The report
is
based on a query with criteria for sales date to get the sales in any
specified date range. I have code in the Format event of the district
group
header. How do I get the count of sales in the current district in the
code
in the Format event of the district group header?

Thanks!

Melissa


Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: asad | last post by:
Hi, i have some problem in showing data. I have two tables First table(containing Hosting categories) Second table(Containg catagories data lik url,keyword,description.....etc) I want to...
2
by: Paxton | last post by:
Hi, I'm trying to display the total page views per page within a given date range, but the correct SQL is seemingly beyond me. I get the correct result with a straightforward Group By and Count...
1
by: Steve Heath | last post by:
I have a query that provides detail for sales transactions meeting certain criteria (date, purchase type, etc.) I am creating a report based on that query, and I want to add a summary section. I...
1
by: seeker52 | last post by:
I receive an error 3464 when I put =count(*) in the controlsource of a textbox on the report header. The error is thrown at the filter created for the report when I docmd openreport. The error is...
5
by: Cro | last post by:
Hello Access Developers, I'd like to know if it is possible to perform a count in an expression that defines a control source. My report is based on a query. In my report, I want a text box to...
2
by: wilscott1st | last post by:
Is it possible in access to select the total count of records for a given group of records and show those all those counts in one report? For example, I have a table of records that contain...
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
4
by: vincibleman | last post by:
Howdy all, Working my way into SQL from Access. Think I might have the hang of the basics, but would really appreciate a sanity check. The stored procedure listed below works, but I can't help...
12
by: petter | last post by:
Hi! I have two questions: one question that regards the COUNT-function, and one about how to display a month even if I don’t have any data for that month. I have an Access database where I want...
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...
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
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.