N
niuginikiwi
Hi people,
Can I use a multiselect (simple) to filter another multiselect (simple)? I
ask this because I don't see a filter property on the data tab of the listbox
properties.
If the above answer is yest then, here is how i am trying to do this.
I got two multiselect listboxes(lstCrops & lstPlantings) on an unbound form,
one based queries.
When I select a CropName from lstCrops which has CropID as bound column,
lstPlanting should be filtered to what selection(s) of CropName I make. There
is a CropID field in the query that is behind lstPlantings.
Here is the code I have on a command button (btnListFilter) to requery the
listbox and apply the filter. When I click btnListFilter, I get this error
message: Wrong number of arguments or invalid property assignment (Error 450)
Private Sub btnListFilter_Click()
On Error GoTo Err_btnListFilter_Click
'Variables
Dim stDocName As ListBox
'Dim frm As Form
Dim strFilter As String
Set stDocName = Me.lstPlantings
'Cycle thru listbox using MultiSelectSQL function
'and assign filter variable with values selected from listbox
strFilter = "CropID" & MultiSelectSQL(lstCrops)
'Requery the listbox and apply filter
DoCmd.Requery stDocName, , , strFilter
Exit_btnListFilter_Click:
Exit Sub
Err_btnListFilter_Click:
MsgBox Err.Description
Resume Exit_btnListFilter_Click
End Sub
Can anyone enlighten me with where I am going astray or rather what I should
do?
Thanks so much in advance.
Can I use a multiselect (simple) to filter another multiselect (simple)? I
ask this because I don't see a filter property on the data tab of the listbox
properties.
If the above answer is yest then, here is how i am trying to do this.
I got two multiselect listboxes(lstCrops & lstPlantings) on an unbound form,
one based queries.
When I select a CropName from lstCrops which has CropID as bound column,
lstPlanting should be filtered to what selection(s) of CropName I make. There
is a CropID field in the query that is behind lstPlantings.
Here is the code I have on a command button (btnListFilter) to requery the
listbox and apply the filter. When I click btnListFilter, I get this error
message: Wrong number of arguments or invalid property assignment (Error 450)
Private Sub btnListFilter_Click()
On Error GoTo Err_btnListFilter_Click
'Variables
Dim stDocName As ListBox
'Dim frm As Form
Dim strFilter As String
Set stDocName = Me.lstPlantings
'Cycle thru listbox using MultiSelectSQL function
'and assign filter variable with values selected from listbox
strFilter = "CropID" & MultiSelectSQL(lstCrops)
'Requery the listbox and apply filter
DoCmd.Requery stDocName, , , strFilter
Exit_btnListFilter_Click:
Exit Sub
Err_btnListFilter_Click:
MsgBox Err.Description
Resume Exit_btnListFilter_Click
End Sub
Can anyone enlighten me with where I am going astray or rather what I should
do?
Thanks so much in advance.