Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default SELECT statement

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default SELECT statement

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default SELECT statement

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Select Case Statement Katie Excel Worksheet Functions 13 December 1st 08 07:32 PM
If Statement to select a letter Karl Excel Worksheet Functions 3 February 8th 08 04:01 PM
SQL Select statement with Date as Pepe[_2_] Excel Programming 3 February 4th 04 06:50 PM
Adding SQL Select Statement Pepe[_2_] Excel Programming 1 January 29th 04 02:19 AM
Wildcard character with Select Statement Mike Excel Programming 1 December 12th 03 07:21 PM


All times are GMT +1. The time now is 11:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"