Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Simple i think.... breaking SQL

My syntax is slightly wrong and having a look on the help file hasnt helped.

This works--------------------------------------------------------------------
Set rs = db.OpenRecordset("SELECT description FROM" & selectTable)

How do i get this to work?---------------------------------------------------
Dim i As String
i= "description"
I have tried this - Set rs = db.OpenRecordset("SELECT" i " FROM" &
selectTable)
+ this - Set rs = db.OpenRecordset("SELECT' i ' FROM" &
selectTable)
+ this - Set rs = db.OpenRecordset("SELECT" & i " FROM" &
selectTable)

im sure the fix is very simple, thanks in advance
--
--
Thanks

Parkin_m
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Simple i think.... breaking SQL

Made it simpler to read below:

'This works
Set rs = db.OpenRecordset("SELECT description FROM" & selectTable)

'Trying to get it so that i can put the column name from a variable
Dim i As String
i= "description"

'none of these work
'Set rs = db.OpenRecordset("SELECT" i " FROM" & selectTable)
'Set rs = db.OpenRecordset("SELECT' i ' FROM" & selectTable)
'Set rs = db.OpenRecordset("SELECT" & i " FROM" & selectTable)

im sure the fix is very simple, thanks in advance
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default Simple i think.... breaking SQL

Hi

Try

Set rs = db.OpenRecordset("SELECT " & i & " FROM" & selectTable)

hth

Keith

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Simple i think.... breaking SQL

You need this:

Dim i As String
i = "description"

Set rs = db.OpenRecordset("SELECT " & i & " FROM " & selectTable)

It won't matter, but I wouldn't pick i for the variable name as this is
normally
for an integer or long variable. Pick something like strField or sField.


RBS


"parkin_m" wrote in message
...
Made it simpler to read below:

'This works
Set rs = db.OpenRecordset("SELECT description FROM" & selectTable)

'Trying to get it so that i can put the column name from a variable
Dim i As String
i= "description"

'none of these work
'Set rs = db.OpenRecordset("SELECT" i " FROM" & selectTable)
'Set rs = db.OpenRecordset("SELECT' i ' FROM" & selectTable)
'Set rs = db.OpenRecordset("SELECT" & i " FROM" & selectTable)

im sure the fix is very simple, thanks in advance


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Simple i think.... breaking SQL

Hahaha. I really should of thought of that! (Silly adding strings!)

Thanks keith.
--
--
Thanks

Parkin_m


"Keith74" wrote:

Hi

Try

Set rs = db.OpenRecordset("SELECT " & i & " FROM" & selectTable)

hth

Keith


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
breaking a field out JCM Excel Worksheet Functions 3 November 11th 08 08:44 AM
Breaking links Jessica Excel Worksheet Functions 1 June 12th 08 11:56 PM
breaking links Pammy Excel Discussion (Misc queries) 1 September 20th 07 05:58 PM
Hyperlinks keep breaking EGNAPM Excel Worksheet Functions 1 September 18th 07 10:10 PM
Breaking a UserForm Daminc[_43_] Excel Programming 18 February 6th 06 11:52 AM


All times are GMT +1. The time now is 08:48 AM.

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"