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

Using OrderBy to dynamically change sort order in reports

The following code is used in my db to change the sort order of the
report to various fields. I want to take this one stage further and
use maybe a Case Select to give 2 or 3 different options to sort the
report.

Is ther any way I can adress the report name as is used in strDocName
and strSQL so instead of having

Reports![Summary Information Report].OrderBy = strSQL

I could Dim reportstr as String

and use

Reports![reportstr].OrderBy = strSQL
This way i could probably hold all of the info in a table and call up
the fields as required to specify report name and sort option...... I
realise it may not be possible, or it may be and it is an issue of
syntax which I have not grasped.
Thanks.

fecket
Example Code

Private Sub annsummaryprev_Click()
On Error GoTo Err_annsummaryprev_Click

DoCmd.SetWarnings False
Dim stDocName As String

stDocName = "Create Summary Info Table Query"
DoCmd.OpenQuery stDocName, acViewNormal

stDocName = "Summary Information Report"

Dim strSQL As String
strSQL = "CatASubmarine"

DoCmd.OpenReport stDocName, acPreview
Reports![Summary Information Report].OrderByOn = True
Reports![Summary Information Report].OrderBy = strSQL
DoCmd.SetWarnings True
Exit_annsummaryprev_Click:
Exit Sub

Err_annsummaryprev_Click:
MsgBox Err.Description
Resume Exit_annsummaryprev_Click

End Sub
Nov 13 '05 #1
1 7920
On Sun, 13 Mar 2005 21:48:14 +0000, fecket <ne*********@hotmail.com>
wrote:

Yes. Use syntax like:
Reports(reportstr).OrderBy = strSQL

-Tom.

The following code is used in my db to change the sort order of the
report to various fields. I want to take this one stage further and
use maybe a Case Select to give 2 or 3 different options to sort the
report.

Is ther any way I can adress the report name as is used in strDocName
and strSQL so instead of having

Reports![Summary Information Report].OrderBy = strSQL

I could Dim reportstr as String

and use

Reports![reportstr].OrderBy = strSQL
This way i could probably hold all of the info in a table and call up
the fields as required to specify report name and sort option...... I
realise it may not be possible, or it may be and it is an issue of
syntax which I have not grasped.
Thanks.

fecket
Example Code

Private Sub annsummaryprev_Click()
On Error GoTo Err_annsummaryprev_Click

DoCmd.SetWarnings False
Dim stDocName As String

stDocName = "Create Summary Info Table Query"
DoCmd.OpenQuery stDocName, acViewNormal

stDocName = "Summary Information Report"

Dim strSQL As String
strSQL = "CatASubmarine"

DoCmd.OpenReport stDocName, acPreview
Reports![Summary Information Report].OrderByOn = True
Reports![Summary Information Report].OrderBy = strSQL
DoCmd.SetWarnings True
Exit_annsummaryprev_Click:
Exit Sub

Err_annsummaryprev_Click:
MsgBox Err.Description
Resume Exit_annsummaryprev_Click

End Sub


Nov 13 '05 #2

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

Similar topics

7
by: juglesh | last post by:
Hello, I would like to be able to have the user sort a list of items similarly to the way you sort your queue on Netflix.com. (the numbers dont change dynamically on netflix, they must be doing...
6
by: P. Emigh | last post by:
By default in more recent versions, Access forms keep users' last sort request in the "orderby" property. That can slow things down considerably, especially when the last user has chosen a...
2
by: DFS | last post by:
Access97: I opened a report, then opened a small form that floats above it and lets you choose report fields to sort on (by issuing the OrderBy statement). Well, apparently OrderBy actually...
2
by: Todd | last post by:
Hello, I'm curious if anyone knows of a way (if one exists) to tell a form (in Access 2002 VBA) to sort on an unbound column of a combo box on the form. Here's what I want to do: A combo box...
2
by: Dutchy | last post by:
Hi there, After spending several hours trying all I could imagine and search for in Google I gave up. In a continuous form I want to sort the choosen column by clicking the header (label) of...
5
by: Otie | last post by:
I have a select query that groups records together, specifically baseball players and their home runs and at-bats. I want to create a query that displays , , and and that sorts ASCENDING on the ...
4
by: lorirobn | last post by:
Hi, I have a main menu that opens several different reports. I am adding an OrderByOn, and currently have it set up for one report with the following statements: !.OrderBy = strOrderBy...
7
by: pbd22 | last post by:
Hi. I really need some advice on fine-tuning a stored procedure that is the meat of the search logic on my site. Customers are allowed to save searches, which dumps the search logic in a table...
2
by: ARC | last post by:
I have a ranking report where I want to sort it different ways depending on the option the user picks. On the On_Open event, I've tried everything I can think of and keep getting error 3071 "This...
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
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
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...

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.