hi,
I want to select table columns through multiselect ListBox in a query.Here is the code
Dim strList
Dim frm As Form, ctl As Control
Dim VarItm As Variant
strList = ""
Set frm = Forms!Form1
Set ctl = frm!List10
For Each VarItm In ctl.ItemsSelected
strList = strList & ctl.ItemData(VarItm) & ", "
Debug.Print ctl.ItemData(VarItm)
Next VarItm
strList = Left(strList, Len(strList) - 2)
CurrentDb.QueryDefs("Query2").SQL = "SELECT " & strList" from Devices where ID= 1"
DoCmd.OutputTo acOutputQuery, "Query2", acFormatXLS
Here the problem is i dont know how to concatinate List values in the query expression.So plz help me.
I want to select table columns through multiselect ListBox in a query.Here is the code
Dim strList
Dim frm As Form, ctl As Control
Dim VarItm As Variant
strList = ""
Set frm = Forms!Form1
Set ctl = frm!List10
For Each VarItm In ctl.ItemsSelected
strList = strList & ctl.ItemData(VarItm) & ", "
Debug.Print ctl.ItemData(VarItm)
Next VarItm
strList = Left(strList, Len(strList) - 2)
CurrentDb.QueryDefs("Query2").SQL = "SELECT " & strList" from Devices where ID= 1"
DoCmd.OutputTo acOutputQuery, "Query2", acFormatXLS
Here the problem is i dont know how to concatinate List values in the query expression.So plz help me.