L
Lambi000
Hi,
I'm back. Here's my code again. I can't seem to get paranthesis around the
selected items and I can't figure out why. I know the thing works if I could
get those things around each selected item, but I can't seem to figure it
out.
Public Function Combo_List()
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim frm As Form
Dim ctl As Control
Dim ctl1 As Control
Dim varItem As Variant
Dim strSQL As String
Set db = CurrentDb()
Set qdf = db.QueryDefs("MultiSelect")
Set frm = Forms![Report Parameters]
Set ctl = frm!List90
Set ctl1 = frm!Text94
strSQL = "Select * from Purchasing Where Purchasing.FirstOfTTYPE = "
'Concatenate to strSQL
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & " OR
Purchasing.FirstOfTTYPE = "
Next varItem
'Trim the end of strSQL
strSQL = Left$(strSQL, Len(strSQL) - 12)
qdf.SQL = strSQL
qdf.Close
DoCmd.OpenQuery "MultiSelect"
Set db = Nothing
Set qdf = Nothing
End Function
NOTE: If I put another paranthesis after the Select statement, I will get a
parenthesis on the left of my item selected.
I'm back. Here's my code again. I can't seem to get paranthesis around the
selected items and I can't figure out why. I know the thing works if I could
get those things around each selected item, but I can't seem to figure it
out.
Public Function Combo_List()
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim frm As Form
Dim ctl As Control
Dim ctl1 As Control
Dim varItem As Variant
Dim strSQL As String
Set db = CurrentDb()
Set qdf = db.QueryDefs("MultiSelect")
Set frm = Forms![Report Parameters]
Set ctl = frm!List90
Set ctl1 = frm!Text94
strSQL = "Select * from Purchasing Where Purchasing.FirstOfTTYPE = "
'Concatenate to strSQL
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & " OR
Purchasing.FirstOfTTYPE = "
Next varItem
'Trim the end of strSQL
strSQL = Left$(strSQL, Len(strSQL) - 12)
qdf.SQL = strSQL
qdf.Close
DoCmd.OpenQuery "MultiSelect"
Set db = Nothing
Set qdf = Nothing
End Function
NOTE: If I put another paranthesis after the Select statement, I will get a
parenthesis on the left of my item selected.