Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I would guess something like this:
"SELECT table1.company FROM pathname WHERE Company_Name =" & "'" & me.combobox1.Value & "'" Where company_name is the column in access where you would look for the value in combobox1. Replace with the real field name. == Regards, Tom Ogilvy "Ali" wrote in message ... Hello, Im trying to retrieve some data from an access table into excel. I have a drop down list, where I want the chosen value to be the criteria for a query statement. How can I use variables to be used as the criteria to filter data within a query statement. "SELECT table1.company FROM pathname WHERE (table1.company = 'value from combo box' " any ideas?? im probably being very thick! many thanks ahead. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You wouldn't use the single quote I don't think
I really am not an expert of formulating SQL queries, but I do know how to concatenate information in string. One thing you might do is turn on the macro recorder and do a Data=Get External Data (then retrieve some data from you source table), then turn off the macro recorder. Then look at the recorded code see how the sql string is recorded. This would give you some insights. Note that a long SQL string will be broken into elements of an array, so you can piece them back together again. -- Regards, Tom Ogilvy "Ali" wrote in message ... thanks, just out of interest is it different for passing integers through? "Tom Ogilvy" wrote: I would guess something like this: "SELECT table1.company FROM pathname WHERE Company_Name =" & "'" & me.combobox1.Value & "'" Where company_name is the column in access where you would look for the value in combobox1. Replace with the real field name. == Regards, Tom Ogilvy "Ali" wrote in message ... Hello, Im trying to retrieve some data from an access table into excel. I have a drop down list, where I want the chosen value to be the criteria for a query statement. How can I use variables to be used as the criteria to filter data within a query statement. "SELECT table1.company FROM pathname WHERE (table1.company = 'value from combo box' " any ideas?? im probably being very thick! many thanks ahead. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Ali,
Ali wrote: thanks, just out of interest is it different for passing integers through? If the database field is a numeric type and not a date, you won't need the single quotes wrapped around the value in your WHERE clause: "SELECT Company_Name FROM table1 WHERE Company_ID =" & me.combobox1.Value -- Regards, Jake Marx MS MVP - Excel www.longhead.com [please keep replies in the newsgroup - email address unmonitored] |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Select Case Statement | Excel Worksheet Functions | |||
If Statement to select a letter | Excel Worksheet Functions | |||
SQL Select statement with Date as | Excel Programming | |||
Adding SQL Select Statement | Excel Programming | |||
Wildcard character with Select Statement | Excel Programming |