Skip to content
Advertisement

DoCmd.OpenReport and ORDER BY in the report

I have a report Email in MS Access and it is now reporting all the sales of the real state. In the report we have the ID, Address, Suburb, Sale Price, Land, Beds, Valuation and Selling Agency.

The code is working now but I want to order it by the SUBURB. I tried to put it in the WhereCondition, but does not work.

I still trying with other options that I found here, like using the OpenArgs arguments in the DoCmd.OpenReport:

This is all my code:

How do I add on to that syntax to put in the Order By criteria? Can someone help me?

Thanks in advance.

Advertisement

Answer

The WhereCondition argument of.OpenReportjust provides a filter string, you can’t sort there.

For some reason, Ms Access reports ignore sort order in their record sourceSQL. To change Order By for report data you have to useGroup & SortonDesign Viewor set theOrderByproperty inReport_Openevent, e.g with theOpenArgsargument ofDoCmd.OpenReport:

Open your report with:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement