Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / December 2005

Tip: Looking for answers? Try searching our database.

Order by

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ACase - 14 Dec 2005 21:06 GMT
Hello;

I created a form which enables a user to select 1 of 3 reports and filter
them using a series of combo boxes.  I now want to create an option box which
would enable him/her to sort the data by the field chosen in the option box.  

My filters are created dynamically using vba code and stored into the
strWhere clause.  They are then executed using:

DoCmd.OpenReport "rpt_Merchant", PrintMode, , strWhere

I now want to add the order by statement, and was hoping to add it to the
strWhere clause

strWhere = strWhere & " ORDER BY " & "Regions.Region"

This however doesn't work.  Is there an easier way to go about this.

Any help would be much appreciated.

Thanks
ACase
Conrad - 14 Dec 2005 22:41 GMT
Why not build the whole sql statement and then assign that to the Record
source of the Report.  That way you can incorporate all sql options.

> Hello;
>
[quoted text clipped - 18 lines]
> Thanks
> ACase
Marshall Barton - 14 Dec 2005 23:54 GMT
>I created a form which enables a user to select 1 of 3 reports and filter
>them using a series of combo boxes.  I now want to create an option box which
[quoted text clipped - 7 lines]
>I now want to add the order by statement, and was hoping to add it to the
>strWhere clause

Even if you could do that, which you can't, it wouldn't work
for anything beyob a trivial report.  The sorting in a
report is specified in the report's Sorting and Grouping
window (View menu).

To provide a user selectable sort field, you need to create
a sort/group level in the report's design.  You can then
modify it at run time by using code in the report's Open
event:

Me.GroupLevel(N).ControlSource = Forms!yourform.sometextbox

That assumes that your form has a (hidden?)text box that
contains the name of the sort field.  The N in the above
needs to be replaced with the appropriate sort/group number.
If you do not have anything else in Sorting and Grouping,
use 0.

Signature

Marsh
MVP [MS Access]

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.