multi select list box if nothing selected


B

babs

I have my report set up to preview when multiple items are selected from the
simple multiselect box. I am populating the list box named lstcategory (cat
#) with field from a linked table. I would like the report -if nothing is
selected in the listbox to print all categories that populate the LIst box.
not sure how to do this???

thanks for your help!
Barb
 
Ad

Advertisements

D

Damon Heron

Create a function in a module:

Public Function BuildWhereCondition(strControl As String) As String
'Set up the WhereCondition Argument for the report
Dim varItem As Variant
Dim strWhereLst As String
Dim ctl As Control

Set ctl = Forms!frmYourFormName!(strControl) 'replace with your form
name that has the listbox

Select Case ctl.ItemsSelected.Count
Case 0 'Include All
strWhereLst = ""
Case 1 'Only One Selected
strWhereLst = "= '" & _
ctl.ItemData(ctl.ItemsSelected(0)) & "'"
Case Else 'Multiple Selection
strWhereLst = " IN ("

With ctl
For Each varItem In .ItemsSelected
strWhereLst = strWhereLst & "'" & .ItemData(varItem) &
"', "
Next varItem
End With
strWhereLst = Left(strWhereLst, Len(strWhereLst) - 2) & ")"
End Select

BuildWhereCondition = strWhereLst
Set ctl = Nothing

End Function

Call the function from your form:
strWhere = BuildWhereCondition("lstcategory")

Then open the report with the conditions of strWhere:
DoCmd.OpenReport stDocName, acPreview, , strWhere

Damon
 
B

babs

not sure where or how to Call the function from the form?? what to i tie it
to - the on click event of the command button to preview the report. also
not sure where to put the DoCmd line(again - On click event of the preview
command button??

thanks,
barb
 
B

babs

Here is the code I actually already have in that works for one or many items
select from the lstcategory list box - I just need to only add to handle
when none is selected to pull up Only the job #'s that are in this List box
(they are based on an sql where ciriteria is set)

would love to just a a few lines to handle if nothing select to preview ALL
of the job#s that are in the list box.

thanks see below:


Private Sub cmdPreview_Click()
On Error GoTo Err_Handler
'Purpose: Open the report filtered to the items selected in the list box.
Dim varItem As Variant 'Selected items
Dim strWhere As String 'String to use as WhereCondition
Dim strDescrip As String 'Description of WhereCondition
Dim lngLen As Long 'Length of string
Dim strDelim As String 'Delimiter for this field type.
Dim strDoc As String 'Name of report to open.

'strDelim = """" 'Delimiter appropriate to field type. See
note 1.
strDoc = "LaborReport2 BP"

'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 = "[JobNbr] IN (" & Left$(strWhere, lngLen) & ")" & " And
[checkDate] >= #" & Me.txtCheckStart & "# And [checkDate] <= #" &
Me.txtCheckEnd & "# AND [Policy Year] = " & Me.cmbPolicy
lngLen = Len(strDescrip) - 2
If lngLen > 0 Then
strDescrip = "Name: " & Left$(strDescrip, lngLen)
End If
End If

'Report will not filter if open, so close it. For Access 97, see note 3.
If CurrentProject.AllReports(strDoc).IsLoaded Then
DoCmd.Close acReport, strDoc
End If




'Omit the last argument for Access 2000 and earlier. See note 4.
DoCmd.OpenReport strDoc, acViewPreview, WhereCondition:=strWhere,
OpenArgs:=strDescrip


Exit_Handler:
Exit Sub

Err_Handler:
If Err.Number <> 2501 Then 'Ignore "Report cancelled" error.
MsgBox "Error " & Err.Number & " - " & Err.Description, ,
"cmdPreview_Click"
End If
Resume Exit_Handler
End Sub
 
D

Damon Heron

Lets say you have a form that has a listbox where user selects items. Have
a command button and for the click event of the command button:
dim strWhere as string
dim stDocName as string
stDocName= "Name of the report"
strWhere = BuildWhereCondition("lstcategory") 'this calls the function and
if no items are selected,
' there is no where condition, so all items print, else selected items print
'next line follows the function call:
DoCmd.OpenReport stDocName, acPreview, , strWhere

Damon
 
D

Damon Heron

Oops! I left out a crucial line, after the function call, you need to
combine the fieldname with the results of the function call:
strWhere = "[Your FieldName] " & strWhere

So the string would look something like this:
"[YourFieldName] IN ('apples','oranges','pears')"

Note that the function deals with text not numbers. You may have to modify
it if you are using
number criteria.

Damon
 
Ad

Advertisements

B

babs

Thanks for your help not sure where to modify code since I am using numbers
and not text?

Thanks again,
Barb
 
D

Damon Heron

In the function, the ' single quotes surround the text, so eliminate those
in the Select Case statement:

Select Case ctl.ItemsSelected.Count
Case 0 'Include All
strWhereLst = ""
Case 1 'Only One Selected
strWhereLst = "= " & _
ctl.ItemData(ctl.ItemsSelected(0)) & " "
Case Else 'Multiple Selection
strWhereLst = " IN ("

With ctl
For Each varItem In .ItemsSelected
strWhereLst = strWhereLst & " " & .ItemData(varItem) &
", "
Next varItem
End With
strWhereLst = Left(strWhereLst, Len(strWhereLst) - 2) & ")"
End Select

Damon
 
B

babs

I am getting a syntax error missing operator IN(-1,-1,-1)

below is the code I put into the function as you suggested - not sure why it
is not pulling up the [jobnbr]

any ideas,
thanks, barb


Private Function BuildWhereCondition(strControl As String) As String
'Set up the WhereCondition Argument for the reports
Dim varItem As Variant
Dim strWhere As String
Dim strWhereLst As String
Dim ctl As Control
Dim strDelim As String 'Delimiter for this field type.

Set ctl = Me.Controls(strControl)


Select Case ctl.ItemsSelected.Count
Case 0 'Include All
strWhereLst = ""
Case 1 'Only One Selected
strWhereLst = "= " & _
ctl.ItemData(ctl.ItemsSelected(0)) & " "
Case Else 'Multiple Selection
strWhereLst = " IN ("

With ctl
For Each varItem In .ItemsSelected
strWhereLst = strWhereLst & " " & .ItemData(varItem) & ", "
Next varItem
End With
strWhereLst = Left(strWhereLst, Len(strWhereLst) - 2) & ")"
End Select

BuildWhereCondition = strWhereLst
Set ctl = Nothing

End Function
 
D

Damon Heron

Did you add the code from my previous post, that reads:

"I left out a crucial line, after the function call, you need to
combine the fieldname with the results of the function call:"

strWhere = "[Your FieldName] " & strWhere

So the string would look something like this:
"[YourFieldName] IN ('apples','oranges','pears')"

So you call the function, and when it returns with the value, you combine
the field name from the listbox that has your Numeric ID #s, and the
combined string is used to restrict your report to just those in the string.
I am troubled by the results you show, though (-1,-1,-1) those should be
unique IDs from the listbox. What is the source of your list box? I am
thinking it should be from a table or query with ID#, Name, etc. and the
function pulls the unique ID for each item in creating the string.
Is that correct?

Damon





babs said:
I am getting a syntax error missing operator IN(-1,-1,-1)

below is the code I put into the function as you suggested - not sure why
it
is not pulling up the [jobnbr]

any ideas,
thanks, barb


Private Function BuildWhereCondition(strControl As String) As String
'Set up the WhereCondition Argument for the reports
Dim varItem As Variant
Dim strWhere As String
Dim strWhereLst As String
Dim ctl As Control
Dim strDelim As String 'Delimiter for this field type.

Set ctl = Me.Controls(strControl)


Select Case ctl.ItemsSelected.Count
Case 0 'Include All
strWhereLst = ""
Case 1 'Only One Selected
strWhereLst = "= " & _
ctl.ItemData(ctl.ItemsSelected(0)) & " "
Case Else 'Multiple Selection
strWhereLst = " IN ("

With ctl
For Each varItem In .ItemsSelected
strWhereLst = strWhereLst & " " & .ItemData(varItem) & ", "
Next varItem
End With
strWhereLst = Left(strWhereLst, Len(strWhereLst) - 2) & ")"
End Select

BuildWhereCondition = strWhereLst
Set ctl = Nothing

End Function
Damon Heron said:
In the function, the ' single quotes surround the text, so eliminate
those
in the Select Case statement:

Select Case ctl.ItemsSelected.Count
Case 0 'Include All
strWhereLst = ""
Case 1 'Only One Selected
strWhereLst = "= " & _
ctl.ItemData(ctl.ItemsSelected(0)) & " "
Case Else 'Multiple Selection
strWhereLst = " IN ("

With ctl
For Each varItem In .ItemsSelected
strWhereLst = strWhereLst & " " & .ItemData(varItem)
&
", "
Next varItem
End With
strWhereLst = Left(strWhereLst, Len(strWhereLst) - 2) & ")"
End Select

Damon
 
B

babs

Yes - I added the [JobNbr] already and not sure why I am getting the
In(-1,-1,-1)

Here is the code I actually already have in that works for one or many items
select from the lstcategory list box - I just need to only add to handle
when none is selected to pull up Only the job #'s that are in this List box
(they are based on an sql where ciriteria is set)

WOULD LOVE to just a a FEW lines to handle if NOTHING select to preview ALL
of the job#s that are IN the LIST box.

thanks see below:


Private Sub cmdPreview_Click()
On Error GoTo Err_Handler
'Purpose: Open the report filtered to the items selected in the list box.
Dim varItem As Variant 'Selected items
Dim strWhere As String 'String to use as WhereCondition
Dim strDescrip As String 'Description of WhereCondition
Dim lngLen As Long 'Length of string
Dim strDelim As String 'Delimiter for this field type.
Dim strDoc As String 'Name of report to open.

'strDelim = """" 'Delimiter appropriate to field type. See
note 1.
strDoc = "LaborReport2 BP"

'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 = "[JobNbr] IN (" & Left$(strWhere, lngLen) & ")" & " And
[checkDate] >= #" & Me.txtCheckStart & "# And [checkDate] <= #" &
Me.txtCheckEnd & "# AND [Policy Year] = " & Me.cmbPolicy
lngLen = Len(strDescrip) - 2
If lngLen > 0 Then
strDescrip = "Name: " & Left$(strDescrip, lngLen)
End If
End If

'Report will not filter if open, so close it. For Access 97, see note 3.
If CurrentProject.AllReports(strDoc).IsLoaded Then
DoCmd.Close acReport, strDoc
End If




'Omit the last argument for Access 2000 and earlier. See note 4.
DoCmd.OpenReport strDoc, acViewPreview, WhereCondition:=strWhere,
OpenArgs:=strDescrip


Exit_Handler:
Exit Sub

Err_Handler:
If Err.Number <> 2501 Then 'Ignore "Report cancelled" error.
MsgBox "Error " & Err.Number & " - " & Err.Description, ,
"cmdPreview_Click"
End If
Resume Exit_Handler
End Sub



Damon Heron said:
Did you add the code from my previous post, that reads:

"I left out a crucial line, after the function call, you need to
combine the fieldname with the results of the function call:"

strWhere = "[Your FieldName] " & strWhere

So the string would look something like this:
"[YourFieldName] IN ('apples','oranges','pears')"

So you call the function, and when it returns with the value, you combine
the field name from the listbox that has your Numeric ID #s, and the
combined string is used to restrict your report to just those in the string.
I am troubled by the results you show, though (-1,-1,-1) those should be
unique IDs from the listbox. What is the source of your list box? I am
thinking it should be from a table or query with ID#, Name, etc. and the
function pulls the unique ID for each item in creating the string.
Is that correct?

Damon





babs said:
I am getting a syntax error missing operator IN(-1,-1,-1)

below is the code I put into the function as you suggested - not sure why
it
is not pulling up the [jobnbr]

any ideas,
thanks, barb


Private Function BuildWhereCondition(strControl As String) As String
'Set up the WhereCondition Argument for the reports
Dim varItem As Variant
Dim strWhere As String
Dim strWhereLst As String
Dim ctl As Control
Dim strDelim As String 'Delimiter for this field type.

Set ctl = Me.Controls(strControl)


Select Case ctl.ItemsSelected.Count
Case 0 'Include All
strWhereLst = ""
Case 1 'Only One Selected
strWhereLst = "= " & _
ctl.ItemData(ctl.ItemsSelected(0)) & " "
Case Else 'Multiple Selection
strWhereLst = " IN ("

With ctl
For Each varItem In .ItemsSelected
strWhereLst = strWhereLst & " " & .ItemData(varItem) & ", "
Next varItem
End With
strWhereLst = Left(strWhereLst, Len(strWhereLst) - 2) & ")"
End Select

BuildWhereCondition = strWhereLst
Set ctl = Nothing

End Function
Damon Heron said:
In the function, the ' single quotes surround the text, so eliminate
those
in the Select Case statement:

Select Case ctl.ItemsSelected.Count
Case 0 'Include All
strWhereLst = ""
Case 1 'Only One Selected
strWhereLst = "= " & _
ctl.ItemData(ctl.ItemsSelected(0)) & " "
Case Else 'Multiple Selection
strWhereLst = " IN ("

With ctl
For Each varItem In .ItemsSelected
strWhereLst = strWhereLst & " " & .ItemData(varItem)
&
", "
Next varItem
End With
strWhereLst = Left(strWhereLst, Len(strWhereLst) - 2) & ")"
End Select

Damon



Thanks for your help not sure where to modify code since I am using
numbers
and not text?

Thanks again,
Barb

:


Create a function in a module:

Public Function BuildWhereCondition(strControl As String) As String
'Set up the WhereCondition Argument for the report
Dim varItem As Variant
Dim strWhereLst As String
Dim ctl As Control

Set ctl = Forms!frmYourFormName!(strControl) 'replace with your
form
name that has the listbox

Select Case ctl.ItemsSelected.Count
Case 0 'Include All
strWhereLst = ""
Case 1 'Only One Selected
strWhereLst = "= '" & _
ctl.ItemData(ctl.ItemsSelected(0)) & "'"
Case Else 'Multiple Selection
strWhereLst = " IN ("

With ctl
For Each varItem In .ItemsSelected
strWhereLst = strWhereLst & "'" &
.ItemData(varItem)
&
"', "
Next varItem
End With
strWhereLst = Left(strWhereLst, Len(strWhereLst) - 2) &
")"
End Select

BuildWhereCondition = strWhereLst
Set ctl = Nothing

End Function

Call the function from your form:
strWhere = BuildWhereCondition("lstcategory")

Then open the report with the conditions of strWhere:
DoCmd.OpenReport stDocName, acPreview, , strWhere

Damon

I have my report set up to preview when multiple items are selected
from
the
simple multiselect box. I am populating the list box named
lstcategory
(cat
#) with field from a linked table. I would like the report -if
nothing
is
selected in the listbox to print all categories that populate the
LIst
box.
not sure how to do this???

thanks for your help!
Barb
 
Ad

Advertisements

B

babs

sorry for not answering the prev. post fully - yes they are unique id's job
numbers from the list box - would love to keep code I just posted and just
add a few lines to handle just the job# from the list box and with the dates
and other fields selected as noted in code.

thanksagain,
barb

Damon Heron said:
Did you add the code from my previous post, that reads:

"I left out a crucial line, after the function call, you need to
combine the fieldname with the results of the function call:"

strWhere = "[Your FieldName] " & strWhere

So the string would look something like this:
"[YourFieldName] IN ('apples','oranges','pears')"

So you call the function, and when it returns with the value, you combine
the field name from the listbox that has your Numeric ID #s, and the
combined string is used to restrict your report to just those in the string.
I am troubled by the results you show, though (-1,-1,-1) those should be
unique IDs from the listbox. What is the source of your list box? I am
thinking it should be from a table or query with ID#, Name, etc. and the
function pulls the unique ID for each item in creating the string.
Is that correct?

Damon





babs said:
I am getting a syntax error missing operator IN(-1,-1,-1)

below is the code I put into the function as you suggested - not sure why
it
is not pulling up the [jobnbr]

any ideas,
thanks, barb


Private Function BuildWhereCondition(strControl As String) As String
'Set up the WhereCondition Argument for the reports
Dim varItem As Variant
Dim strWhere As String
Dim strWhereLst As String
Dim ctl As Control
Dim strDelim As String 'Delimiter for this field type.

Set ctl = Me.Controls(strControl)


Select Case ctl.ItemsSelected.Count
Case 0 'Include All
strWhereLst = ""
Case 1 'Only One Selected
strWhereLst = "= " & _
ctl.ItemData(ctl.ItemsSelected(0)) & " "
Case Else 'Multiple Selection
strWhereLst = " IN ("

With ctl
For Each varItem In .ItemsSelected
strWhereLst = strWhereLst & " " & .ItemData(varItem) & ", "
Next varItem
End With
strWhereLst = Left(strWhereLst, Len(strWhereLst) - 2) & ")"
End Select

BuildWhereCondition = strWhereLst
Set ctl = Nothing

End Function
Damon Heron said:
In the function, the ' single quotes surround the text, so eliminate
those
in the Select Case statement:

Select Case ctl.ItemsSelected.Count
Case 0 'Include All
strWhereLst = ""
Case 1 'Only One Selected
strWhereLst = "= " & _
ctl.ItemData(ctl.ItemsSelected(0)) & " "
Case Else 'Multiple Selection
strWhereLst = " IN ("

With ctl
For Each varItem In .ItemsSelected
strWhereLst = strWhereLst & " " & .ItemData(varItem)
&
", "
Next varItem
End With
strWhereLst = Left(strWhereLst, Len(strWhereLst) - 2) & ")"
End Select

Damon



Thanks for your help not sure where to modify code since I am using
numbers
and not text?

Thanks again,
Barb

:


Create a function in a module:

Public Function BuildWhereCondition(strControl As String) As String
'Set up the WhereCondition Argument for the report
Dim varItem As Variant
Dim strWhereLst As String
Dim ctl As Control

Set ctl = Forms!frmYourFormName!(strControl) 'replace with your
form
name that has the listbox

Select Case ctl.ItemsSelected.Count
Case 0 'Include All
strWhereLst = ""
Case 1 'Only One Selected
strWhereLst = "= '" & _
ctl.ItemData(ctl.ItemsSelected(0)) & "'"
Case Else 'Multiple Selection
strWhereLst = " IN ("

With ctl
For Each varItem In .ItemsSelected
strWhereLst = strWhereLst & "'" &
.ItemData(varItem)
&
"', "
Next varItem
End With
strWhereLst = Left(strWhereLst, Len(strWhereLst) - 2) &
")"
End Select

BuildWhereCondition = strWhereLst
Set ctl = Nothing

End Function

Call the function from your form:
strWhere = BuildWhereCondition("lstcategory")

Then open the report with the conditions of strWhere:
DoCmd.OpenReport stDocName, acPreview, , strWhere

Damon

I have my report set up to preview when multiple items are selected
from
the
simple multiselect box. I am populating the list box named
lstcategory
(cat
#) with field from a linked table. I would like the report -if
nothing
is
selected in the listbox to print all categories that populate the
LIst
box.
not sure how to do this???

thanks for your help!
Barb
 
Ad

Advertisements

D

Damon Heron

Okay just looking at your code, you need an else condition when you test for
the length of strWhere
If lngLen > 0 Then 'user made selections
strWhere = "[JobNbr] IN (" & Left$(strWhere, lngLen) & ")" & " And
[checkDate] >= #" & Me.txtCheckStart & "# And [checkDate] <= #" &
Me.txtCheckEnd & "# AND [Policy Year] = " & Me.cmbPolicy
lngLen = Len(strDescrip) - 2

****If lngLen > 0 Then ' don't need this line -you have already tested
for lngLen >0
strDescrip = "Name: " & Left$(strDescrip, lngLen)

Else ' if lngLen =0 then no strWhere so no selections made in listbox. so
strWhere = "[checkDate] >= #" & Me.txtCheckStart & "# And [checkDate] <=
#" &
Me.txtCheckEnd & "# AND [Policy Year] = " & Me.cmbPolicy

End If

Untested code!
Damon

babs said:
sorry for not answering the prev. post fully - yes they are unique id's
job
numbers from the list box - would love to keep code I just posted and just
add a few lines to handle just the job# from the list box and with the
dates
and other fields selected as noted in code.

thanksagain,
barb

Damon Heron said:
Did you add the code from my previous post, that reads:

"I left out a crucial line, after the function call, you need to
combine the fieldname with the results of the function call:"

strWhere = "[Your FieldName] " & strWhere

So the string would look something like this:
"[YourFieldName] IN ('apples','oranges','pears')"

So you call the function, and when it returns with the value, you combine
the field name from the listbox that has your Numeric ID #s, and the
combined string is used to restrict your report to just those in the
string.
I am troubled by the results you show, though (-1,-1,-1) those should be
unique IDs from the listbox. What is the source of your list box? I am
thinking it should be from a table or query with ID#, Name, etc. and the
function pulls the unique ID for each item in creating the string.
Is that correct?

Damon





babs said:
I am getting a syntax error missing operator IN(-1,-1,-1)

below is the code I put into the function as you suggested - not sure
why
it
is not pulling up the [jobnbr]

any ideas,
thanks, barb


Private Function BuildWhereCondition(strControl As String) As String
'Set up the WhereCondition Argument for the reports
Dim varItem As Variant
Dim strWhere As String
Dim strWhereLst As String
Dim ctl As Control
Dim strDelim As String 'Delimiter for this field type.

Set ctl = Me.Controls(strControl)


Select Case ctl.ItemsSelected.Count
Case 0 'Include All
strWhereLst = ""
Case 1 'Only One Selected
strWhereLst = "= " & _
ctl.ItemData(ctl.ItemsSelected(0)) & " "
Case Else 'Multiple Selection
strWhereLst = " IN ("

With ctl
For Each varItem In .ItemsSelected
strWhereLst = strWhereLst & " " & .ItemData(varItem) & ", "
Next varItem
End With
strWhereLst = Left(strWhereLst, Len(strWhereLst) - 2) & ")"
End Select

BuildWhereCondition = strWhereLst
Set ctl = Nothing

End Function
:

In the function, the ' single quotes surround the text, so eliminate
those
in the Select Case statement:

Select Case ctl.ItemsSelected.Count
Case 0 'Include All
strWhereLst = ""
Case 1 'Only One Selected
strWhereLst = "= " & _
ctl.ItemData(ctl.ItemsSelected(0)) & " "
Case Else 'Multiple Selection
strWhereLst = " IN ("

With ctl
For Each varItem In .ItemsSelected
strWhereLst = strWhereLst & " " &
.ItemData(varItem)
&
", "
Next varItem
End With
strWhereLst = Left(strWhereLst, Len(strWhereLst) - 2) &
")"
End Select

Damon



Thanks for your help not sure where to modify code since I am using
numbers
and not text?

Thanks again,
Barb

:


Create a function in a module:

Public Function BuildWhereCondition(strControl As String) As String
'Set up the WhereCondition Argument for the report
Dim varItem As Variant
Dim strWhereLst As String
Dim ctl As Control

Set ctl = Forms!frmYourFormName!(strControl) 'replace with your
form
name that has the listbox

Select Case ctl.ItemsSelected.Count
Case 0 'Include All
strWhereLst = ""
Case 1 'Only One Selected
strWhereLst = "= '" & _
ctl.ItemData(ctl.ItemsSelected(0)) & "'"
Case Else 'Multiple Selection
strWhereLst = " IN ("

With ctl
For Each varItem In .ItemsSelected
strWhereLst = strWhereLst & "'" &
.ItemData(varItem)
&
"', "
Next varItem
End With
strWhereLst = Left(strWhereLst, Len(strWhereLst) - 2) &
")"
End Select

BuildWhereCondition = strWhereLst
Set ctl = Nothing

End Function

Call the function from your form:
strWhere = BuildWhereCondition("lstcategory")

Then open the report with the conditions of strWhere:
DoCmd.OpenReport stDocName, acPreview, , strWhere

Damon

I have my report set up to preview when multiple items are
selected
from
the
simple multiselect box. I am populating the list box named
lstcategory
(cat
#) with field from a linked table. I would like the report -if
nothing
is
selected in the listbox to print all categories that populate the
LIst
box.
not sure how to do this???

thanks for your help!
Barb
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top