How do I use a form to collect parameters for a report?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I followed the directions from an article in the database including
inserting all of the pertinent VBA code but when after I click OK on the
collection form with the drop down box, all I get is the actual datasheet
view of the parameter query. Somehting is missing that allows the report to
display.

Can anyone help? Or suggest an easier way to program this form.

Thanks
 
Sorry that would help.

Code that was placed on the colection form open event:

Private Sub Form_Open(Cancel As Integer)
If Not bInReportOpenEvent Then

MsgBox "For Use from Report Only", vbOKOnly
Cancel = True
End If
Form_Open_Exit:
Exit Sub
End Sub

Code that was placed on the OK command Button OnClick Event:

Private Sub Ok_Click()
Me.Visible = False
DoCmd.OpenQuery "qryShowPlanNewbySupervisor", acViewNormal, acEdit
DoCmd.Close acForm, "frmSchedulebySupervisor"
End Sub

Code that was placed on the Report OPen Event

Private Sub Report_Open(Cancel As Integer)
bInReportOpenEvent = True

DoCmd.OpenForm "frmSchedulebySupervisor", , , , , acDialog

If IsLoaded("frmSchedulebySupervisor") = False Then Cancel = True

bInReportOpenEvent = False
End Sub
 
Sleepless -

It appears that the code is correct. Does the code function as planned when
running the report? If you open the form and select a parameter, the report
will not display. The report must be opened which will open the collection
form.

One suggestion I would make is to add the line

DoCmd.close acQuery, "qryShowPlanNewbySupervisor"

in the Ok_Click event after you open the query and close the collection form.
 
I don't see any code like:
DoCmd.OpenReport....
I think you need to change this line:
DoCmd.OpenQuery "qryShowPlanNewbySupervisor", acViewNormal, acEdit
Your code tells the query to open, not the report.
 
Back
Top