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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL where function???

Status
Not open for further replies.

AccessDevJunior

Programmer
Apr 14, 2004
81
GB
hya,
i have 2 list boxes, i would like the second listbox based on the first by using SQL, this is what i have tried but it seems to have failed:

dim clist as string
clist = ListCompany.List(ListCompany.ListIndex)

SQL = "SELECT tblEmployeeInfo.[Employee Department]From tblEmployeeInfo Where (((tblEmployeeInfo.[Employee Company]) = 'Clist' ))GROUP BY tblEmployeeInfo.[Employee Department];"

so my app is retreiving information from an access database where 'employee company' = the value of my apps first listbox.

im not sure why this does not work,
do i have to refer to the app first so:
clist = myappsfilepath.ListCompany.List(ListCompany.ListIndex)

if anyone knows a solution to this or point me in the right direction it would be a great help
 
You are embeding the word "Clist" into the SQL string rather than adding the value of the variable clist to the string. Do this:

SQL = "SELECT tblEmployeeInfo.[Employee Department]From tblEmployeeInfo Where (((tblEmployeeInfo.[Employee Company]) = '" & clist & "' ))GROUP BY tblEmployeeInfo.[Employee Department];"

Hope this helps.

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top