R
Rita
Hi,
I want to use a criteria form that has a multi-select list box where a user
can select several companies and also type in a date range for several
different reports. Each report is built on a different query or queries. The
reports would not all be run at the same time. I know I have to loop through
the items in the list box. I found this sample code on Allen Browne's
website that will use a list box to select multiple categories in a report,
but the multi-select criteria form opens only one report. Is it possible to
use this in reverse? Open a report and have the report call the criteria
form?
If I can open the desired report and have it open the multi-select criteria
form I can use such a form for many reports that all have a different record
source while selecting what companies I want the report for. I apologize if
I'm not explaining this clearly.
The sample code is below is in the cmdPreview button on the criteria form
from Mr. Browne's website.
strDoc = "Products by Category" ' (my comment, this report name would not
always be the same)
'Loop through the ItemsSelected in the list box.
With Me.lstCategory
For Each varItem In .ItemsSelected
If Not IsNull(varItem) Then
'Build up the filter from the bound column (hidden).
strWhere = strWhere & strDelim & .ItemData(varItem) &
strDelim & ","
'Build up the description from the text in the visible
column. See note 2.
strDescrip = strDescrip & """" & .Column(1, varItem) & """,
"
End If
Next
End With
'Remove trailing comma. Add field name, IN operator, and brackets.
lngLen = Len(strWhere) - 1
If lngLen > 0 Then
strWhere = "[CategoryID] IN (" & Left$(strWhere, lngLen) & ")"
lngLen = Len(strDescrip) - 2
If lngLen > 0 Then
strDescrip = "Categories: " & Left$(strDescrip, lngLen)
End If
End If
Thank you in advance.
RT
I want to use a criteria form that has a multi-select list box where a user
can select several companies and also type in a date range for several
different reports. Each report is built on a different query or queries. The
reports would not all be run at the same time. I know I have to loop through
the items in the list box. I found this sample code on Allen Browne's
website that will use a list box to select multiple categories in a report,
but the multi-select criteria form opens only one report. Is it possible to
use this in reverse? Open a report and have the report call the criteria
form?
If I can open the desired report and have it open the multi-select criteria
form I can use such a form for many reports that all have a different record
source while selecting what companies I want the report for. I apologize if
I'm not explaining this clearly.
The sample code is below is in the cmdPreview button on the criteria form
from Mr. Browne's website.
strDoc = "Products by Category" ' (my comment, this report name would not
always be the same)
'Loop through the ItemsSelected in the list box.
With Me.lstCategory
For Each varItem In .ItemsSelected
If Not IsNull(varItem) Then
'Build up the filter from the bound column (hidden).
strWhere = strWhere & strDelim & .ItemData(varItem) &
strDelim & ","
'Build up the description from the text in the visible
column. See note 2.
strDescrip = strDescrip & """" & .Column(1, varItem) & """,
"
End If
Next
End With
'Remove trailing comma. Add field name, IN operator, and brackets.
lngLen = Len(strWhere) - 1
If lngLen > 0 Then
strWhere = "[CategoryID] IN (" & Left$(strWhere, lngLen) & ")"
lngLen = Len(strDescrip) - 2
If lngLen > 0 Then
strDescrip = "Categories: " & Left$(strDescrip, lngLen)
End If
End If
Thank you in advance.
RT