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

Code question

Status
Not open for further replies.

ozzroo

Technical User
Feb 28, 2003
182
AU
I have a list of reports in a combo box and a frame that has 2 options Print Report or View Report.

Is there a way I can write code that will print or view the report selected in the combo box. At the moment I have code like

If cboReportsList = "2" And PrintOptions = "1" Then
DoCmd.OpenReport "rptXXXXXX" acPreview.........


But if I have like 100 reports my code is going to be long. Can I print according to a where statement?
 

If all of your reports, are available for printing then load the combo with this select statement

SELECT M.Name
FROM MSysObjects As M
WHERE Type=-32764

else make a table for those reports to store their names

SELECT myReportName FROM myReportsTable

then in a button
chetck the option and define the second argument either to be acViewNormal=0 or acViewPreview=2

If OptionView.Value = True Then
docmd.OpenReport cboReportsList.Text, 0
Else
docmd.OpenReport cboReportsList.Text, 2
End If

 
The actual report list in a combo box is an autolookup

So the first combo is like:

Management Reports
Admin Reports
Sales Reports

Then the combo box with the reports will be determined by the selection in the first combo.

All the reports are already in a table.

So how would I incorporate your code into the setup I have.
 

If OptionView.Value = True Then
docmd.OpenReport cboReportsList.Text, 0
Else
docmd.OpenReport cboReportsList.Text, 2
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top