G
Guest
I'm trying to remember ( and I wasn't ever really good at it) how to take
infromation from a list box, save selected items in another to be used as
query crieteria. I can generate the second list. However, the query doesn't
like the info. Now what. Here's what I have so far.
Public myTablist As Variant
Public varTablist As Variant
Public myTabNames
Sub RowsSelected()
Dim ctlTabs As Control
Dim myInt1 As Integer
Dim myVar1
' Return Control object variable pointing to list box.
Set ctlTabs = Forms!frmMainQuery!cboTabList
' Enumerate through selected items.
For Each varTablist In ctlTabs.ItemsSelected
' Print value of bound column.
If myInt1 = 0 Then
cmbTabListRpt.RowSource = ctlTabs.ItemData(varTablist)
myTablist = ctlTabs.ItemData(varTablist)
Else
cmbTabListRpt.RowSource = myVar1 & ";" &
ctlTabs.ItemData(varTablist)
myTablist = "'" & myTablist & "'" & " Or " & "'" &
ctlTabs.ItemData(varTablist) & "'"
End If
myVar1 = cmbTabListRpt.RowSource
myInt1 = myInt1 + 1
Next varTablist
txtTabList = myTablist
End Sub
Private Sub cboTabList_AfterUpdate()
Call RowsSelected
End Sub
infromation from a list box, save selected items in another to be used as
query crieteria. I can generate the second list. However, the query doesn't
like the info. Now what. Here's what I have so far.
Public myTablist As Variant
Public varTablist As Variant
Public myTabNames
Sub RowsSelected()
Dim ctlTabs As Control
Dim myInt1 As Integer
Dim myVar1
' Return Control object variable pointing to list box.
Set ctlTabs = Forms!frmMainQuery!cboTabList
' Enumerate through selected items.
For Each varTablist In ctlTabs.ItemsSelected
' Print value of bound column.
If myInt1 = 0 Then
cmbTabListRpt.RowSource = ctlTabs.ItemData(varTablist)
myTablist = ctlTabs.ItemData(varTablist)
Else
cmbTabListRpt.RowSource = myVar1 & ";" &
ctlTabs.ItemData(varTablist)
myTablist = "'" & myTablist & "'" & " Or " & "'" &
ctlTabs.ItemData(varTablist) & "'"
End If
myVar1 = cmbTabListRpt.RowSource
myInt1 = myInt1 + 1
Next varTablist
txtTabList = myTablist
End Sub
Private Sub cboTabList_AfterUpdate()
Call RowsSelected
End Sub