Combo Boxes to Open Reports

Miten

New member
Local time
Today, 16:00
Joined
Feb 25, 2007
Messages
5
I have a form with a combo box where i entered certain data in.. i also have a button on the form. What id like to do is that when a certain thing is selected in the combo box, to print preview that corresponding report.

I had some code in the button starting with something similar to:

If Combo1.Rowsource = ("Report1") Then
Run.Macro ("Report1")
End If

Where the Macro Report1 opens that report in print preview. The problem with this is that it doesn't open the report.. im pretty sure the bold part of that code is false since i made it up using logic. In fact.. all of it is probably wrong.

Thanks in advance
 
Why not start by letting the Command Button Wizard create a botton that will run a report for you. Then you can modify the code created to look at your ComboBox and run *that* report.
 
I have this code now:

Private Sub Command8_Click()
Dim stDocName As String
stDocName = "Report1"

If Combo5.RowSource = ("Report1") Then
DoCmd.OpenReport stDocName, acPreview
End If

End Sub

Still doesn't work =/

Also tried

If Combo5.RowSource = ("Report1") Then
DoCmd.OpenReport (Report1), acViewPreview

End If
 
Last edited:
I'm going to guess that your ComboBox RowSourceType is a ValueList. If so then change your code to simply:
Code:
Private Sub Command8_Click()

DoCmd.OpenReport Me.Combo5, acPreview

End Sub
You could also put this code in the AfterUpdate event of the ComboBox and eliminate the Command Button.
 
TY RG... that was just what i was looking for.
 

Users who are viewing this thread

Back
Top Bottom