Access VB- Using values in a combo boxes on a form as the input parameter to a report
Hello VB Experts,
For Access 2000: My objective is to create a code that when the user hit
the command button to preview a report, the user can have the option of choosing
the parameter on the form as the input to the report selected. Basically,
the form has two combo boxes, a partner's name and a publication name. The
user has three combination choices-either choose by a partner and a publication(All
those contacts who are on this partner's list and who are receiving this
publication) or just by partner(All those contacts who are on this partner's
list) or just by publication(All those contacts who are receiving this publication,
doesn't matter who partners's list are they on). After the user selects
the choices from the combo boxes, he/she can choose the type of reports that
they want from the option group box on the form.
The problem is that I can't get the filter to understand that when user leaves
either the partner or publication combo box blank, it means no filter applies-e.g.
select all records based on this partner or select all records based on this
publication. Right now the form works only when both the partner and publication
combo box have a value in it. It doesn't work with null. Instead of creating
separate forms for the partner combo box or the publication combo box and
separate reports for each report type, is there a way/code to get the program
to understand the null values in a those two combo boxes? Is there another
method that I can use?
Any help that you can give me, will be deeply appreciated?
Private Sub Print_Click()
On Error GoTo Err_Print_Click
'Ignore filter when the combo box has a null value
If Combo0 = Null Then
If Combo2 = Null Then
' Open a mailing labels report with a filter
Dim strFilter As String, strReportName As String
' Determine which mailing labels user wants.
Select Case MailingType
strReportName = "rptFullPartnerContact"
strReportName = "rptFullPublicationContact"
strReportName = "rptGTFBMailingLabels"
strReportName = "rptPubSmallMailingLabels"
strReportName = "rptSmallMailingLabels"
strReportName = "rptPartnerContact"
strReportName = "rptShortPartnerContact"
strReportName = "rptPublicationContact"
DoCmd.OpenReport strReportName, acViewPreview, , strFilter
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center