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

Reports in Combobox

Status
Not open for further replies.

Jengo

Programmer
Apr 17, 2000
100
US
How can I get the list of reports I have in a database into a combobox? I want to be able to select a certain report and be able to print it from the form.
 
Hi Jengo,
You can do it with this nifty query:

SELECT MSysObjects.Name AS ReportName FROM MSysObjects WHERE (((MSysObjects.Type)=-32764));

Paste that into a new query in SQL view.

Now perhaps your combo is called Combo1, and you have a command button to print the report, your command buttons "On Click" event would look something like this:

Private Sub Command4_Click()
On Error GoTo Err_Command4_Click

Dim stDocName As String

stDocName = Me.Combo1 '<-Look here!
DoCmd.OpenReport stDocName, acPreview

Exit_Command4_Click:
Exit Sub

Err_Command4_Click:
MsgBox Err.Description
Resume Exit_Command4_Click
End Sub

Your combo should be 1 column and you should set a default value for your combobox just to be safe if someone clicks the button when the combo is empty. That'll do it! Gord
ghubbell@total.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top