Results 1 to 3 of 3

Thread: FROM syntax not recognizing table

  1. #1

    FROM syntax not recognizing table

    Good day all, I am hoping someone can shine the light on my mistakes.
    I have an ADO code the runs in excel pulling info from an MS access DB.
    The issue is when I pull FROM a table that has one word it works fine but if the table has more than one word with a space etc it does not work.
    If i replace the "Profiles 3-4" below with one word like "Helmet" it works but i have so many tables in my DB renaming all to a single word is not realistic. Any help would be apprecited.
    BTW im not new to excel VBA but access i am ver much a novice.
    This is the selection of code where it errors:
    Set Recordset = New ADODB.Recordset 
    With Recordset 
         '       Filter
        Src = "SELECT * FROM Profiles 3-4 WHERE BDE = 'HBCT' " 
    Formatting tags added by mark007

  2. #2
    If possible, rename the table to a single word with no spaces, punctuation marks, etc. ... begin the name with a letter, and use only letters, digits, and the underscore character for the rest of the name.

    If you must keep that name, surround it with square brackets to avoid confusing the database engine.

    Src = "SELECT * FROM [Profiles 3-4] WHERE BDE = 'HBCT' " 
    Formatting tags added by mark007

  3. #3
    Moderator VBAX Master geekgirlau's Avatar
    Aug 2004
    Melbourne, Australia
    hansup makes an excellent point. It's a good idea when setting up your database to not include spaces in the name of anything - tables, fields, queries, forms ...

    I'd suggest you do some reading on the Leszynski/Reddick naming conventions - it's a good habit to get into, and makes your database much easier to maintain.

    We are what we repeatedly do. Excellence, therefore, is not an act but a habit.

Posting Permissions

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