Help with Command Button (1 Viewer)

Beefboy

New member
Local time
Today, 23:39
Joined
Feb 20, 2000
Messages
5
Here is what I am trying to do. I have about 30 reports in a list box. I want to be able to select a report and push a command button so it runs the report I have just selected.

Couple of Details/Questions
I typed all the report names into a list box
Should I use a combo box?
Should I type these report names into a table then link it to a combo or list box?

Any help is appreciated..
 

Hunter

Registered User.
Local time
Today, 23:39
Joined
Feb 2, 2000
Messages
24
I have done this using code in the CLick Event of the button that opens the selected report.

Private Sub cmdReports_Click()
On Error GoTo Err_cmdReports_Click

Dim rptSelected As String
Dim stDocName As String

rptSelected = Me.ReportComboBox.Value

Select Case rptSelected
Case "Report One"
stDocName = "Report One"
Case "Report Two”
stDocName = "Report Two"
Case "Report Three"
stDocName = "Report Three”
End Select

DoCmd.OpenReport stDocName, acPreview

Exit_cmdReports_Click:
Exit Sub

Err_cmdReports_Click:
MsgBox Err.Description
Resume Exit_cmdReports_Click

End Sub
 

Beefboy

New member
Local time
Today, 23:39
Joined
Feb 20, 2000
Messages
5
Thanks..!!

I will try it out and let you know...
 

Beefboy

New member
Local time
Today, 23:39
Joined
Feb 20, 2000
Messages
5
Hey Hunter..

Thanks for the code. Everything works great!
 
D

Duckman

Guest
is there a way to get the names of the reports to populate the combo box without typing them in manually?
 

skiphooper

Registered User.
Local time
Today, 18:39
Joined
Nov 29, 2000
Messages
76
Hi Duckman,
Here is a query I got from this site a while ago which is what you are looking for.
Use this query as the recordsource for your combo box.
=======================================
SELECT [MSysObjects].[Name]
FROM MsysObjects
WHERE (Left$([Name],1)<>"~") And ([MSysObjects].[Type])=-32764
ORDER BY [MSysObjects].[Name];
========================================
HTH
Skip
 

Users who are viewing this thread

Top Bottom