List Box - stLinkCriteria

S

S. Jackson

I have a dialog form for users to select certain criteria before printing
reports. Some of the reports (not all) allow the user to make a selection
from the ActionListbox. When they do the following runs behind the View
Report command button:

'if report can be printed using action criteria, and user selects same

If Me.ActionListBx.ItemsSelected.Count > 0 Then

stLinkCriteria = stLinkCriteria & " AND [tblCaseInfo]![Action]IN ("
For Each varItem In Me.ActionListBx.ItemsSelected
stLinkCriteria = stLinkCriteria & _
Chr$(34) & _
Me.ActionListBx.ItemData(varItem) & _
Chr$(34) & ","
Next varItem
stLinkCriteria = Left(stLinkCriteria, Len(stLinkCriteria) - 1) & ")"

End If

The problem I'm having is that if a user selects a report that allows him to
select criteria from the ActionListBx, then goes back and selects a report
that does NOT allow a selection from the ActionListBx, I get a request to
enter a Action Parameter when the query for that report runs because the
code above still thinks that Me.ActionListBx.ItemsSelected.Count is >0. How
do I return the value of the ActionListBx.ItemsSelected.Count to Zero? And,
can I do this before the End If statement, or do I need to put it under the
AfterUpdate Event on the ReportListBx?

TIA
Shelly
 
N

Naresh Nichani MVP

Hi:

Try this after the Report runs

Dim i As Integer

For i = 0 To Me.ActionListBx.ListCount - 1
Me.ActionListBx.Selected(i) = False
Next

Regards,

Naresh Nichani
Microsoft Access MVP
 
S

S. Jackson

Thank you! I had a little bit of thinking about where to put the code.
After trial and error, I put it in the AfterUpdate event of my Report
Selection List Box and it works perfectly.

Thanks again!
Shelly

Naresh Nichani MVP said:
Hi:

Try this after the Report runs

Dim i As Integer

For i = 0 To Me.ActionListBx.ListCount - 1
Me.ActionListBx.Selected(i) = False
Next

Regards,

Naresh Nichani
Microsoft Access MVP

S. Jackson said:
I have a dialog form for users to select certain criteria before printing
reports. Some of the reports (not all) allow the user to make a selection
from the ActionListbox. When they do the following runs behind the View
Report command button:

'if report can be printed using action criteria, and user selects same

If Me.ActionListBx.ItemsSelected.Count > 0 Then

stLinkCriteria = stLinkCriteria & " AND [tblCaseInfo]![Action]IN ("
For Each varItem In Me.ActionListBx.ItemsSelected
stLinkCriteria = stLinkCriteria & _
Chr$(34) & _
Me.ActionListBx.ItemData(varItem) & _
Chr$(34) & ","
Next varItem
stLinkCriteria = Left(stLinkCriteria, Len(stLinkCriteria) - 1) & ")"

End If

The problem I'm having is that if a user selects a report that allows
him
to
select criteria from the ActionListBx, then goes back and selects a report
that does NOT allow a selection from the ActionListBx, I get a request to
enter a Action Parameter when the query for that report runs because the
code above still thinks that Me.ActionListBx.ItemsSelected.Count is >0. How
do I return the value of the ActionListBx.ItemsSelected.Count to Zero? And,
can I do this before the End If statement, or do I need to put it under the
AfterUpdate Event on the ReportListBx?

TIA
Shelly
 

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