Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selection of Table Fields through ListBox

Status
Not open for further replies.

yummy7

Technical User
Jun 2, 2006
195
CA
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.
 
Duplicate post. See:
Selection of Table columns through MultiSelect ListBox
thread702-1242015
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top