Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OpenReport

Status
Not open for further replies.

Cybermac

IS-IT--Management
Jun 6, 2003
18
0
0
PH
Good day guys, I have a question how do I sort a field in my report form using DOCMD.OpenReport command? what syntax do I use?

Thanks.
 
Cybermac

Doesn't Access prompt you with the syntax as you type?

docmd.OpenReport ("ReportName", acViewNormal , "MyFilter", "MyWhere", acWindowNormal , "MyOpenArgs")

Explanation:
"ReportName" - kind of obvious
acViewNormal - this specifies what type of window to use - normal is probably what you want
MyFilter - would be a filter to apply to the report
MyWhere - would be your where clause for the report
acWindowNormal - type of window to use, again Normal is most common.
MyOpenArgs" - you can pass text to the report that is read as "openning arguments". From the coding level, you can use this to have more control over the report beyond the Filter or Where clause.

Having said all this, most of the time just the defualts would be used, so the above command line may become...
docmd.OpenReport ("ReportName", , , , , )

Richard
 
Thanks Richard, what if I would like to sort my fields where do I put my fields in open report command?
 
Per help in MS Access Help, you probably want to use the filter option...

Filter Name A filter that restricts the report's records. You can enter the name of either an existing query or a filter that was saved as a query. However, the query must include all the fields in the report you are opening or have its OutputAllFields property set to Yes.
 
Sorry willir I'm newbie in ms access can you give me an example coding?

Thanks again
 
Got it!!!!

I do this:

DoCmd.OpenReport "Report name", acViewDesign

Reports![report name].RecordSource = "SELECT * FROM table ORDER BY field1"

DoCmd.OpenReport "Report name", acViewPreview

But guys do you have any coding to make it simplier without using acViewdesign?
 
Office uses various "constants". Now, acViewDeisgn = 1, so you could use
DoCmd.OpenReport "Report name", 1

But when you later "read" your code, you have to remember, research on what the heck "1" means when you open a report.

It is much easier for readability to use the name of constant -- ahhh, now I know I want to open the report in design mode, not normal mode.

Your choice, but the verbose way may save you some pain later on.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top