473,770 Members | 3,983 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Crosstab query reports (unknown fields in reports) What about sorting?

Hi,

I've been trying to work out how to create a report based on crosstab
query for which the number of fields is variable. For example in a
situation where you show customer billing by year in the following
format:

Customer 2000 2001 2002
Bill 103 10 205
Frank 12 50
George 200 50

where you might need a new column to appear where 2003 or 1999
billings are in the data.

The good news is that I've come across some really clever code in the
"bible" (Access 2000 Developers Handbook) which can do this. No doubt
this code is readily available in other places too.

Basically the code is placed in the report's open event and it
populates the controls in the report so that they link up with the
field in the cross tab query. (Let me know if I need to expand on
this).

My problem now though is that I want to sort this data by the billings
(eg 2002, then 2001 then 2000).

My thinking here that there must be a relatively easy way to include
something in the code which populated the Grouping and Sorting
property of the form.

Anyone know what the code is? or have a better idea?

Mat
Nov 13 '05 #1
3 5228
You can assign the ControlSource of the GroupLevel in Report_Open.

Example at:
http://allenbrowne.com/ser-33.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Mat N" <Ma******@hotma il.com> wrote in message
news:d2******** *************** **@posting.goog le.com...

I've been trying to work out how to create a report based on crosstab
query for which the number of fields is variable. For example in a
situation where you show customer billing by year in the following
format:

Customer 2000 2001 2002
Bill 103 10 205
Frank 12 50
George 200 50

where you might need a new column to appear where 2003 or 1999
billings are in the data.

The good news is that I've come across some really clever code in the
"bible" (Access 2000 Developers Handbook) which can do this. No doubt
this code is readily available in other places too.

Basically the code is placed in the report's open event and it
populates the controls in the report so that they link up with the
field in the cross tab query. (Let me know if I need to expand on
this).

My problem now though is that I want to sort this data by the billings
(eg 2002, then 2001 then 2000).

My thinking here that there must be a relatively easy way to include
something in the code which populated the Grouping and Sorting
property of the form.

Anyone know what the code is? or have a better idea?

Mat

Nov 13 '05 #2
Allen,

Just what I needed. Thanks.

Just to complete the thread here's the bit of code the solved my
problem:

'Fill in information for the necessary controls.
For i = 1 To intColCount
strName = rst.Fields(i - 1).Name
Me.Controls("lb lHeader" & i).Caption = strName
Me.Controls("tx tData" & i).ControlSourc e = strName
Me.Controls("tx tSum" & i).ControlSourc e = _
"=Sum([" & strName & "])"
If i > 1 Then
Me.GroupLevel(i - 1).ControlSourc e = strName
Me.GroupLevel(i - 1).SortOrder = True
End If
Next i

Notice that I included "SortOrder" which when true means descending
and also the if statement avoids sorting by the first field.

Mat N

"Allen Browne" <Al*********@Se eSig.Invalid> wrote in message news:<40******* *************** *@per-qv1-newsreader-01.iinet.net.au >...
You can assign the ControlSource of the GroupLevel in Report_Open.

Example at:
http://allenbrowne.com/ser-33.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Mat N" <Ma******@hotma il.com> wrote in message
news:d2******** *************** **@posting.goog le.com...

I've been trying to work out how to create a report based on crosstab
query for which the number of fields is variable. For example in a
situation where you show customer billing by year in the following
format:

Customer 2000 2001 2002
Bill 103 10 205
Frank 12 50
George 200 50

where you might need a new column to appear where 2003 or 1999
billings are in the data.

The good news is that I've come across some really clever code in the
"bible" (Access 2000 Developers Handbook) which can do this. No doubt
this code is readily available in other places too.

Basically the code is placed in the report's open event and it
populates the controls in the report so that they link up with the
field in the cross tab query. (Let me know if I need to expand on
this).

My problem now though is that I want to sort this data by the billings
(eg 2002, then 2001 then 2000).

My thinking here that there must be a relatively easy way to include
something in the code which populated the Grouping and Sorting
property of the form.

Anyone know what the code is? or have a better idea?

Mat

Nov 13 '05 #3
Actually the code I used didn't appear to work properly but I've
worked out the problem.

Basically the code would work except that Grouplevels can only be
created in design view.

The work around is to create dummy grouplevel in the design view which
you edit later using the same code. I designed my report so that it
can show up 7 columns of numbers and so I've simply created the
Grouplevel using the following expressions:

=2
=3
....
=6
=7

It shouldn't matter what you use so long as it is an expression and
you have enough to cover the maximum number of group levels you might
need.

Works a treat now.

Mat N

Ma******@hotmai l.com (Mat N) wrote in message news:<d2******* *************** ****@posting.go ogle.com>...
Allen,

Just what I needed. Thanks.

Just to complete the thread here's the bit of code the solved my
problem:

'Fill in information for the necessary controls.
For i = 1 To intColCount
strName = rst.Fields(i - 1).Name
Me.Controls("lb lHeader" & i).Caption = strName
Me.Controls("tx tData" & i).ControlSourc e = strName
Me.Controls("tx tSum" & i).ControlSourc e = _
"=Sum([" & strName & "])"
If i > 1 Then
Me.GroupLevel(i - 1).ControlSourc e = strName
Me.GroupLevel(i - 1).SortOrder = True
End If
Next i

Notice that I included "SortOrder" which when true means descending
and also the if statement avoids sorting by the first field.

Mat N

"Allen Browne" <Al*********@Se eSig.Invalid> wrote in message news:<40******* *************** *@per-qv1-newsreader-01.iinet.net.au >...
You can assign the ControlSource of the GroupLevel in Report_Open.

Example at:
http://allenbrowne.com/ser-33.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Mat N" <Ma******@hotma il.com> wrote in message
news:d2******** *************** **@posting.goog le.com...

I've been trying to work out how to create a report based on crosstab
query for which the number of fields is variable. For example in a
situation where you show customer billing by year in the following
format:

Customer 2000 2001 2002
Bill 103 10 205
Frank 12 50
George 200 50

where you might need a new column to appear where 2003 or 1999
billings are in the data.

The good news is that I've come across some really clever code in the
"bible" (Access 2000 Developers Handbook) which can do this. No doubt
this code is readily available in other places too.

Basically the code is placed in the report's open event and it
populates the controls in the report so that they link up with the
field in the cross tab query. (Let me know if I need to expand on
this).

My problem now though is that I want to sort this data by the billings
(eg 2002, then 2001 then 2000).

My thinking here that there must be a relatively easy way to include
something in the code which populated the Grouping and Sorting
property of the form.

Anyone know what the code is? or have a better idea?

Mat

Nov 13 '05 #4

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

Similar topics

6
8686
by: Dave | last post by:
I came across an article in SQL Mag about Crosstab Queries. It works great in Query Analyzer, but I'm stuck on how to use it in an Access ADP. I need to use it as a Recordsource in a form and report. Can someone tell me how to use it, and please try to be as descriptive as possible. I'm new to Stored Procedures. Thanks *****************************************
8
7589
by: Donna Sabol | last post by:
First, I should start by saying I am creating a database to be used by some very impatient, non-computer literate people. It needs to be seameless in it's operation from their point of view. I want them to do as little as possible when they run their reports. I have a crosstab query that displays usage of items for each month. It looks pretty much like this: ITEM DESC UM 12/02 1/03 2/03 3/03 ...ETC. 1 Solution ...
1
17673
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to Create a Dynamic Crosstab Report PRODUCT :Microsoft Access PROD/VER:1.00 1.10 OPER/SYS:WINDOWS
10
1669
by: pw | last post by:
Hi, Is that possible if the crosstab query is dynamic? Doesn't seem so as I have to specify the control source for the text boxes and the number of columns may change, along with their field names. Just thought I'd take a shot in the dark. -pw
1
3337
by: Richard Hollenbeck | last post by:
Hello Newsgroup. You have all been very helpful in the past and I thank you. I try to ask relevant questions so that they don't just benefit me, but also benefit the group. I'm currently overwhelmed by useless examples across the web on how to make "dynamic crosstab reports" without myself having a basic understanding about how to retrieve and assign recordsources, etc., from fields in a query to fields in the report. I see all these...
2
6525
by: luca varani | last post by:
I would like to sort the results of a crosstab query by the aggregate function it automatically generates (total of the values in each column of the crosstab). If I simply put "ascending" in the sort field of the design view I get the following error message: "cannot have aggregate function in order by clause". I had no success trying to edit the sql statement directly, either. I looked quite a while for help inside access or online...
14
3500
by: Tina | last post by:
My employer tracks productivity/performance of clinicians (how much they bill) each week, its averages for the month, and the 6 months. These averages are compared to their expected productivity. However, the expectation changes - it may be 60% for a while, then change to 50%. Initially, I was averaging the expectation, along with the productivity, but what I'm being asked is to look at the average productivity/performance compared to...
6
4480
by: tizmagik | last post by:
I am having a lot of difficulty generating a CrossTab Query based report. I have looked online for several tutorials and whatnot but I have not been able to really find what I'm looking for, nor have I been able to adapt other people's solutions/tips to fit what I need. If anyone could please help me with the following it would be really appreciated, thank you! I need to generate a Report (say: repCrossTab) that grabs it's data from the...
0
2323
by: Peter Herath | last post by:
I want to create a custormizable report . For an example, there's a form with four combo boxes and two of them having database tables columns/field names as values in the combo box(one for select row filed and other one for select column filed in the report) when u select items in that combo boxes and press a Button then selected items should go to the crosstab query as parameters and execute the query. upto that i have done my coding part but...
0
9591
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10057
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10002
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7415
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3970
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3575
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.