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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open a report from a combo box 1

Status
Not open for further replies.

malcprice

Technical User
Feb 27, 2002
20
GB
I wish to open a report from a combo box.

The combo box will list a numve of reports which the user can select.

How is this possible and what kind of code/macro would I need to use to complete this

Many thanks

 
Assumptions:
Combobox Name is cboReport

In the afterupdate event of the combobox or the onclick of some command button, put the following:

DoCmd.OpenReport Me![cboReport], acViewPreview

If you place this in the afterupdate event of the combobox, the report will open immediately after you select one...if you place it in a command button, you cans elect the report, then click the button to open the report.

****************************
Only two things are infinite, the universe and human stupidity,
and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III
MCSA, CNA, MCP, Network+, A+
w: robert.l.johnson.iii@citigroup.com
h: wildmage@tampabay.rr.com
 
What options do I enter into the combo boxes? the report names or something else

many thanks
 
Ah....I thought you already had that....

OKay, two things to consider. If you have only a few reports, then I would just enter the names in as values....if you have a whole bunch, or if they may change often, I would create dynamic function to get the currently list and display these...

****************************
Only two things are infinite, the universe and human stupidity,
and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III
MCSA, CNA, MCP, Network+, A+
w: robert.l.johnson.iii@citigroup.com
h: wildmage@tampabay.rr.com
 
malcprice,

Don't know if you've solved your problem yet .... this works for me.

In the row source for the combo box enter:

"SELECT Mid([Name],4) AS Expr1 From MSysObjects WHERE (((MSysObjects.Type) = -32764) And ((Left([Name], 3)) = ""rpt""))ORDER BY Mid([Name],4);"

This will generate a dynamic list of report names. The query needs the first 3 letters of the report name to be "rpt". This way you won't get your subreports in the combo box.... if you've tagged them correctly. ;-)

dlind
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top