Z
Zach
Hello, I am trying to work though getting multiple muliselect listboxes to
work. Got the first one to work but I can't get the second one to work.
They are going to be cascading to filter a subform.
my code that doesn't work is:
Private Sub BarType_Click()
Dim MyDB2 As Database
Dim qdf2 As QueryDef
Dim i2 As Integer, strSQL2 As String
Dim strwhere2 As String, strIN2 As String
Dim ctl2 As Control
Dim frm2 As Form
Dim varItm2 As Variant
sDocName2 = "BarInquiry SearchBarTypes"
Set MyDB2 = CurrentDb()
Set frm2 = Forms!BarInquiry
Set ctl2 = frm2!BarType
strSQL2 = "SELECT bar.[BAR TYPE], bar.COUNTDATE , bar.length, bar.[bar
size] FROM Bar" 'this is the table that the listbox is built from.
For Each varItm2 In ctl2.ItemsSelected
strIN2 = strIN2 & "'" & ctl2.ItemData(varItm2) & "',"
Next varItm2
strwhere2 = " WHERE ((([Bar].[BAR TYPE]) in (" & Left(strIN2,
Len(strIN2) - 1) & ")))"
strSQL2 = strSQL2 & strwhere2
Me.Refresh
On Error Resume Next
MyDB2.QueryDefs.Delete sDocName2
Forms![BarInquiry subform].Form!RecordSource = strSQL2
End Sub
any help?
Thanks!
work. Got the first one to work but I can't get the second one to work.
They are going to be cascading to filter a subform.
my code that doesn't work is:
Private Sub BarType_Click()
Dim MyDB2 As Database
Dim qdf2 As QueryDef
Dim i2 As Integer, strSQL2 As String
Dim strwhere2 As String, strIN2 As String
Dim ctl2 As Control
Dim frm2 As Form
Dim varItm2 As Variant
sDocName2 = "BarInquiry SearchBarTypes"
Set MyDB2 = CurrentDb()
Set frm2 = Forms!BarInquiry
Set ctl2 = frm2!BarType
strSQL2 = "SELECT bar.[BAR TYPE], bar.COUNTDATE , bar.length, bar.[bar
size] FROM Bar" 'this is the table that the listbox is built from.
For Each varItm2 In ctl2.ItemsSelected
strIN2 = strIN2 & "'" & ctl2.ItemData(varItm2) & "',"
Next varItm2
strwhere2 = " WHERE ((([Bar].[BAR TYPE]) in (" & Left(strIN2,
Len(strIN2) - 1) & ")))"
strSQL2 = strSQL2 & strwhere2
Me.Refresh
On Error Resume Next
MyDB2.QueryDefs.Delete sDocName2
Forms![BarInquiry subform].Form!RecordSource = strSQL2
End Sub
any help?
Thanks!