feathers212
Registered User.
- Local time
- Today, 01:03
- Joined
- Jan 3, 2007
- Messages
- 27
I have a form with list boxes and several subforms. Multiple items can be selected from each list box. Based on the selections from the list boxes, the subforms (based on one main query) display the proper filtered information.
The problem is that I need to be able to select multiple items from each list box. I have created an AfterUpdate event that creates a string value based on the selected items and stores that value in a text box on the form. The following is an example of the criteria created from values from one of the list boxes:
So if Category 1, Category 2, and Category 5 are selected from the CategoryList list box, the CatParam text box shows: 'Category 1' Or 'Category 2' Or 'Category 5'
This works just fine.
I then have the main query (which then drives the information for the subforms) pulling its criteria fields from the main form using the following: [Forms]![Main Form]![CatParam]
This is where things don't work. If I manually enter the 'Category 1' Or 'Category 2' Or 'Category 5' into the query criteria, everything works. But referencing the form's text box does nothing. The query results in no records displayed.
Any thoughts, ideas, suggestions??
The problem is that I need to be able to select multiple items from each list box. I have created an AfterUpdate event that creates a string value based on the selected items and stores that value in a text box on the form. The following is an example of the criteria created from values from one of the list boxes:
Code:
Private Sub CategoryList_AfterUpdate()
Dim ctlSource As Control
Dim strCatCriteria As String
Dim intCurrentRow As Integer
strCatCriteria = ""
Set ctlSource = Me!CategoryList
For intCurrentRow = 0 To ctlSource.ListCount - 1
If ctlSource.Selected(intCurrentRow) Then
If strCatCriteria = "" Then
strCatCriteria = "'" & ctlSource.Column(0, intCurrentRow) & "'"
Else
strCatCriteria = strCatCriteria & " Or '" & ctlSource.Column(0, intCurrentRow) & "'"
End If
Else: End If
Next intCurrentRow
CatParam.Value = strCatCriteria
Exit Sub
So if Category 1, Category 2, and Category 5 are selected from the CategoryList list box, the CatParam text box shows: 'Category 1' Or 'Category 2' Or 'Category 5'
This works just fine.
I then have the main query (which then drives the information for the subforms) pulling its criteria fields from the main form using the following: [Forms]![Main Form]![CatParam]
This is where things don't work. If I manually enter the 'Category 1' Or 'Category 2' Or 'Category 5' into the query criteria, everything works. But referencing the form's text box does nothing. The query results in no records displayed.
Any thoughts, ideas, suggestions??