473,698 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_annsummaryp rev_Click

DoCmd.SetWarnin gs False
Dim stDocName As String

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

stDocName = "Summary Information Report"

Dim strSQL As String
strSQL = "CatASubmar ine"

DoCmd.OpenRepor t stDocName, acPreview
Reports![Summary Information Report].OrderByOn = True
Reports![Summary Information Report].OrderBy = strSQL
DoCmd.SetWarnin gs True
Exit_annsummary prev_Click:
Exit Sub

Err_annsummaryp rev_Click:
MsgBox Err.Description
Resume Exit_annsummary prev_Click

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

Yes. Use syntax like:
Reports(reports tr).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_annsummaryp rev_Click

DoCmd.SetWarni ngs False
Dim stDocName As String

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

stDocName = "Summary Information Report"

Dim strSQL As String
strSQL = "CatASubmar ine"

DoCmd.OpenRepor t stDocName, acPreview
Reports![Summary Information Report].OrderByOn = True
Reports![Summary Information Report].OrderBy = strSQL
DoCmd.SetWarnin gs True
Exit_annsummar yprev_Click:
Exit Sub

Err_annsummary prev_Click:
MsgBox Err.Description
Resume Exit_annsummary prev_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
2927
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 something serverside with them) Like this: ( represents a text or select filed) an item something else a differnt thing the other
6
6934
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 non-indexed field. I have put in a lot of OrderBy = "" code in OnOpen form events. Being able to disable that "service" (seems like more and more Microsoft insists on helping when we don't need or want the help) would be a much more efficient...
2
1855
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 closes and reopens the report in the chosen sort order, because my Report_Close and Report_Open events were firing each time I set the OrderBy value from the form.
2
6156
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 on my form contains a category ID (bound column, not visible, long integer) for the items listed on the form and a description (unbound column, visible, string.) I can "Sort Ascending" and "Sort Descending" on the visible description in the...
2
3351
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 that column. I even want to sort up and down if one clicks again on the same header. No problem so far, all works well for one column. Now I want to sort on the first choosen column ASC or DESC and additionally on a second column ASC. I use the...
5
1759
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 field. My field is: AB_per_HR: / If I set the SORT to Ascending, I get an error message saying I tried
4
8535
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 !.OrderByOn = True I would like to set those statements up using a variable for report name. Is that possible? For instance, it would be something like:
7
2988
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 called SavedSearches for later access to the search. My problem started with the ORDERBY condition used for zipcode searches. The condition did something like: "order by CASE WHEN userID=67 THEN 1 WHEN userID=103 THEN 2 WHEN
2
5444
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 expression is typed incorrectly or is too complex..." Here's the 2 things I've tried, both return the error 3071. If I comment out the code, the report opens normally. The fields SumOfInvTot, Margin, MarginPCT, and Comp all exist both in the...
0
8603
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
9027
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...
0
8861
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6518
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
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3046
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
2329
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
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.