Hello all,
I have a form that has a unbound field based on a query. Next to it, I have a command button to preview a report based on the selection of the unbound field. For example, a user selects a location from the drop down list. They click the preview button but it's returns a blank report. I have the exact same code on the same form to view a name selected the same way and it works perfectly. Can someone tell be why it doesn't work for location but works for name Here's my code for both the location and name:
doesn't work
works
Both reports are based on a query with a criteria to point to the unbound field: [forms]![frmreportbuilder]![Combo8]
I have a form that has a unbound field based on a query. Next to it, I have a command button to preview a report based on the selection of the unbound field. For example, a user selects a location from the drop down list. They click the preview button but it's returns a blank report. I have the exact same code on the same form to view a name selected the same way and it works perfectly. Can someone tell be why it doesn't work for location but works for name Here's my code for both the location and name:
doesn't work
Code:
Private Sub CmdPreviewBranch_Click() On Error GoTo err_CmdPreviewBranch Dim rptdocname As String rptdocname = "rptOccur_Branch" DoCmd.OpenReport rptdocname, acViewPreview exit_CmdPreviewBranch_Click: Exit Sub err_cmdpreviewBranch_Click MsgBox Err.Description Resume Exit_cmdPreviewBranch_Click End Sub
works
Code:
Private Sub cmdPreview_Click() On Error GoTo Err_cmdPreview_Click Dim rptdocname As String rptdocname = "rptOccur_Member" DoCmd.OpenReport rptdocname, acPreview Exit_cmdPreview_Click: Exit Sub Err_cmdPreview_Click: MsgBox Err.Description Resume Exit_cmdPreview_Click End Sub
Both reports are based on a query with a criteria to point to the unbound field: [forms]![frmreportbuilder]![Combo8]

report won't run
Srilatha
Innovactive Engineering s.r.l.
Turbond
Hi
I think the point I was trying to make is that you need to be sure that something has been selected in the Combo box on the form. When I load my forms I normally make a default selection so that there is a value. Try printing the selection to the debug window to be sure what is being passed.
If there is a value in your combo box, you need to consider if the correct result of the query is an empty recordset, it may be there is no data matching the selection.