SQL statement in VBA

  • Thread starter Thread starter Michael Malinsky
  • Start date Start date
M

Michael Malinsky

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.
 
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.
 
Roedd said:
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.
 
Roedd said:
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.
 
Tom,

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

Mike.
 
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>
 
Back
Top