J
Jeff Conrad
Hi,
Using Access 97 here.
Background:
I have a form that launches four different vendor reports.
Each of these reports have no sub-reports. By using option
boxes on the form the user can select to print all the
vendors or by using a list box they can pick and choose
which ones to print. With help supplied here long ago I
use the following code in each Report's Open event to
filter the vendor list like so:
(Excuse the line wrapping)
If [Forms]![frmVendorReports]![lstVendors].Enabled = False
Then
'Skip over the filter area
Else
Dim frm As Form, ctl As Control
Dim varItm As Variant
Dim strFilter As String
Set frm = Forms!frmVendorReports
Set ctl = frm!lstVendors
For Each varItm In ctl.ItemsSelected
strFilter = strFilter & "VendorID=" &
ctl.ItemData(varItm) & " OR "
Next varItm
strFilter = Left(strFilter, Len(strFilter) - 4)
FilterOn = True
Filter = strFilter
End If
This code works beautifully for these four reports. If the
list box is enabled then the filter string is built based
on what items were selected. Keep in mind this works
PERFECT for these four reports!
Now I created two additional vendor reports. Using Duane
Hookom's samples as a guide I created a report that lists
all the order days and one for all the delivery days. They
each have seven sub-reports (one for each day) like a
weekly calendar. Each report looks GREAT and works just
fine by itself showing all vendors with orders/deliveries.
I want to now launch these reports from the same form and
give the user the ability to select only one or several
vendors to display if they so desire. Still with me?
Problem:
Well I thought all I needed to do was add the same code to
the Open event of the subreport. Wrong. It doesn't work. I
receive the following error:
"Run-Time Error 2101:
The setting you entered isn't valid for this property.
To see the valid settings for this property, search the
Help index for the name of the property."
The debugger stops on:
FilterOn = True
I don't get it! I stepped through the code and the Filter
string is built up perfectly. Looking at Help says nothing
that you can't have a filter on a sub-report. If I move
the code to the main report, it does absolutely nothing.
So why is this code failing on a sub-report?
Any thoughts or suggestions are welcome.
Jeff Conrad
Bend, Oregon
Using Access 97 here.
Background:
I have a form that launches four different vendor reports.
Each of these reports have no sub-reports. By using option
boxes on the form the user can select to print all the
vendors or by using a list box they can pick and choose
which ones to print. With help supplied here long ago I
use the following code in each Report's Open event to
filter the vendor list like so:
(Excuse the line wrapping)
If [Forms]![frmVendorReports]![lstVendors].Enabled = False
Then
'Skip over the filter area
Else
Dim frm As Form, ctl As Control
Dim varItm As Variant
Dim strFilter As String
Set frm = Forms!frmVendorReports
Set ctl = frm!lstVendors
For Each varItm In ctl.ItemsSelected
strFilter = strFilter & "VendorID=" &
ctl.ItemData(varItm) & " OR "
Next varItm
strFilter = Left(strFilter, Len(strFilter) - 4)
FilterOn = True
Filter = strFilter
End If
This code works beautifully for these four reports. If the
list box is enabled then the filter string is built based
on what items were selected. Keep in mind this works
PERFECT for these four reports!
Now I created two additional vendor reports. Using Duane
Hookom's samples as a guide I created a report that lists
all the order days and one for all the delivery days. They
each have seven sub-reports (one for each day) like a
weekly calendar. Each report looks GREAT and works just
fine by itself showing all vendors with orders/deliveries.
I want to now launch these reports from the same form and
give the user the ability to select only one or several
vendors to display if they so desire. Still with me?
Problem:
Well I thought all I needed to do was add the same code to
the Open event of the subreport. Wrong. It doesn't work. I
receive the following error:
"Run-Time Error 2101:
The setting you entered isn't valid for this property.
To see the valid settings for this property, search the
Help index for the name of the property."
The debugger stops on:
FilterOn = True
I don't get it! I stepped through the code and the Filter
string is built up perfectly. Looking at Help says nothing
that you can't have a filter on a sub-report. If I move
the code to the main report, it does absolutely nothing.
So why is this code failing on a sub-report?
Any thoughts or suggestions are welcome.
Jeff Conrad
Bend, Oregon