I tried 2 different ways under the OnOpen on the report and in both I get the
same message to enter parameter value. Can someone please help me figure out
what I am doing wrong. I have no idea what I am doing.
My form name is Select Unit Classification and the combo box name is
UnitClassification.
Here is what I entered in the MVS:
Private Sub UnitClassification_Click()
On Error GoTo UnitClassification_Click_Err
If (IsNull(UnitClassification)) Then
Beep
End If
If (Not IsNull(Callnummer)) Then
DoCmd.OpenForm "[Select Unit Classification]", acNormal, "",
"[cboUnitClassification]=" & UnitClassification
acFormEdit , acWindowNormal
On Error Resume Next
DoCmd.Requery ""
End If
UnitClassification_Click_Exit:
Exit Sub
UnitClassification_Click_Err:
MsgBox Error$
Resume UnitClassification_Click_Exit
End Sub
Second try:
Private Sub Report_Load()
Me.Visible = False
DoCmd.OpenForm "Selec Unit Classification", , , , , acDialog
Me.Filter = "Unitclassification = """ & Forms![Select Unit
Classification] & """"
Me.FilterOn = True
DoCmd.Close acForm, "Select Unit Classification"
Me.Visible = True
End Sub
Dale Fye said:
Arlene, I generally create a Reports form, which lists all of the reports,
and which contains all of the various fields that I might want to filter the
report on (usually on several different tabs, as each report may have fields
specific to that report). I fill in the filter parameters on that form, and
hit the "Preview" button to view the report with filters applied.
Having said that, I've been wanting to look into the feasibilty of doing
this since someone asked about having a combo box popup instead of an input
box for a parameter query. So, I created a filtering form (frm_Test) with a
textbox and a command button. In the Click event of the command button, you
need to hide the form (me.visible = false), which will allow the code in the
reports Load event to resume processing. I modified the Reports Load event
as indicated below.
Private Sub Report_Load()
Me.Visible = False
DoCmd.OpenForm "frm_Test", , , , , acDialog
Me.Filter = "Act_FY = """ & Forms!frm_Test.txt_FY & """"
Me.FilterOn = True
DoCmd.Close acForm, "frm_Test"
Me.Visible = True
End Sub
It worked superbly. I then modified the textbox to a combobox and that
worked too.