combo box select when opening report

P

Pasquale

How can I get a combo box to come up when previewing a report so that
the user can select an event name and then print preview the report
specific to that event?

In the "On Open" event of the report I've tried
'Forms![Events2]![EventName]' and in the text box of the report I have
the "control source" as '=Forms!Events2!EventName.Value'. Using these
results in '#Error' being displayed in where the text box is.

Any help or direction would be appreciated.

Pasquale
 
R

Reggie

Pasquale, Just pass the argument to the open report procedure like so(replace the names with the
names of your controls)

Private Sub cmdMyButton_Click()
On Error GoTo Err_cmdMyButton_Click

Dim stDocName As String

stDocName = "rptYourReport"
DoCmd.OpenReport stDocName, acPreview, , "[EventName] = '" & Me.cboEvent & "'"

Exit_cmdMyButton_Click:
Exit Sub

Err_cmdMyButton_Click:
MsgBox Err.Number & Err.Description
Resume Exit_cmdMyButton_Click

End Sub

Hope I understood your request. If not post back!
 
P

Pieter Linden

Pasquale said:
How can I get a combo box to come up when previewing a report so that
the user can select an event name and then print preview the report
specific to that event?

In the "On Open" event of the report I've tried
'Forms![Events2]![EventName]' and in the text box of the report I have
the "control source" as '=Forms!Events2!EventName.Value'. Using these
results in '#Error' being displayed in where the text box is.

Any help or direction would be appreciated.

Pasquale

DO it the other way around. Open it from a an unbound form with the
combobox on it and then reference that in the filter.
 
Top