Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default SQL statement in VBA

Hello all,

I know how to create an SQL statement in VBA, but the problem that I'm
running into with this one particular database (not of my design) is
that the tables and queries have names that contain spaces (i.e.,
Customer List). Apparently the SQL statement doesn't like the space in
the table/query name. I've tried a couple of different things without
success. Can anyone help with with this problem?

Thanks,
Mike.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default SQL statement in VBA

Have you tried recording a macro using Get external data. You can then look
at the SQL portion and get some hints. I think the answer is to use single
quotes, but don't do that much with SQL.

--
Regards,
Tom Ogilvy

"Michael Malinsky" wrote in message
ups.com...
Hello all,

I know how to create an SQL statement in VBA, but the problem that I'm
running into with this one particular database (not of my design) is
that the tables and queries have names that contain spaces (i.e.,
Customer List). Apparently the SQL statement doesn't like the space in
the table/query name. I've tried a couple of different things without
success. Can anyone help with with this problem?

Thanks,
Mike.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default SQL statement in VBA

Roedd <<Michael Malinsky wedi ysgrifennu:

I know how to create an SQL statement in VBA, but the problem that I'm
running into with this one particular database (not of my design) is
that the tables and queries have names that contain spaces (i.e.,
Customer List). Apparently the SQL statement doesn't like the space
in the table/query name. I've tried a couple of different things
without success. Can anyone help with with this problem?


What couple of things? You're in danger here of getting loads of replies
with stuff you've already tried.

Put the field names in [] square brackets.

--
Rob

http://www.asta51.dsl.pipex.com/webcam/

This message is copyright Robert Bruce and intended
for distribution only via NNTP.
Dissemination via third party Web forums with the
exception of Google Groups and Microsoft Communities
is strictly prohibited and may result in legal action.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default SQL statement in VBA

Roedd <<Robert Bruce wedi ysgrifennu:

Put the field names in [] square brackets.


Oh dear. Typo. I meant Table and/or query names, though I generally put all
Field, Table AND query names in square brackets just to be on the safe
side - Jet in particular has some obscure and seemingly ever-changing
reserved words.

--
Rob

http://www.asta51.dsl.pipex.com/webcam/

This message is copyright Robert Bruce and intended
for distribution only via NNTP.
Dissemination via third party Web forums with the
exception of Google Groups and Microsoft Communities
is strictly prohibited and may result in legal action.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default SQL statement in VBA

Tom,

Thanks for that suggestion. The answer was to enclose the table/query
name in backticks (``).

Mike.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default SQL statement in VBA

Thanks for coming back with that. I have to confess that is what I was
thinking of, but didn't know what to call them or really exactly what they
were (and hoped single quotes would work as well). <g

--
Regards,
Tom Ogilvy

"Michael Malinsky" wrote in message
oups.com...
Tom,

Thanks for that suggestion. The answer was to enclose the table/query
name in backticks (``).

Mike.



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
IF statement inside a SUMIF statement.... or alternative method Sungibungi Excel Worksheet Functions 3 December 4th 09 06:22 PM
Reconcile Bank statement & Credit card statement & accounting data Bklynhyc Excel Worksheet Functions 0 October 7th 09 09:07 PM
Embedding an OR statement in an IF statement efficiently Chatnoir11 Excel Discussion (Misc queries) 4 February 2nd 09 08:12 PM
appending and IF statement to an existing IF statement spence Excel Worksheet Functions 1 February 28th 06 11:00 PM
If statement and Isblank statement Rodney C. Excel Worksheet Functions 0 January 18th 05 08:39 PM


All times are GMT +1. The time now is 01:51 AM.

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

About Us

"It's about Microsoft Excel"