I have a Form with a list box set to mulit Select Simple. I want to use that list box in a query.
The Form Name is frmAccount. The List box name is AcctType_ListBox. I am using a textbox named AcctType to store the listbox selection values separated by commas.
The code and query is below. The in statement in the query does not work. Help!
Private Sub AccountType_ListBox_AfterUpdate()
Call ListSelectedItems
End Sub
Private Sub ListSelectedItems()
Dim v As Variant
Dim s As String
For Each v In Me.AcctType_ListBox.ItemsSelected
If s <> "" Then
s = s & ", "
End If
s = s & "'" & Me.AcctType_ListBox.ItemData(CLng(v)) & "'"
Next v
Me.AccountType.Value = s
End Sub
The Query is:
Select tblmain1.*
FROM tblmain1
WHERE name In ([Forms]![frmAccount]![AcctType])
The Form Name is frmAccount. The List box name is AcctType_ListBox. I am using a textbox named AcctType to store the listbox selection values separated by commas.
The code and query is below. The in statement in the query does not work. Help!
Private Sub AccountType_ListBox_AfterUpdate()
Call ListSelectedItems
End Sub
Private Sub ListSelectedItems()
Dim v As Variant
Dim s As String
For Each v In Me.AcctType_ListBox.ItemsSelected
If s <> "" Then
s = s & ", "
End If
s = s & "'" & Me.AcctType_ListBox.ItemData(CLng(v)) & "'"
Next v
Me.AccountType.Value = s
End Sub
The Query is:
Select tblmain1.*
FROM tblmain1
WHERE name In ([Forms]![frmAccount]![AcctType])