+ Reply to Thread
Results 1 to 6 of 6

SQL statement in VBA

  1. #1
    Michael Malinsky
    Guest

    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. #2
    Tom Ogilvy
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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. #3
    Robert Bruce
    Guest

    Re: 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. #4
    Robert Bruce
    Guest

    Re: 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. #5
    Michael Malinsky
    Guest

    Re: SQL statement in VBA

    Tom,

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

    Mike.


  6. #6
    Tom Ogilvy
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > Tom,
    >
    > Thanks for that suggestion. The answer was to enclose the table/query
    > name in backticks (``).
    >
    > Mike.
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1