VBA Express Forum  




Go Back   VBA Express Forum > VBA Code & Other Help > Access Help
     Feedback     
Register FAQ Members Arcade Knowledge Base Training Articles Consulting

Reply
 
Thread Tools Display Modes
Old 03-15-2012, 09:25 AM   #1
RKeev

 
Joined: Mar 2012
Posts: 1
Kb Entries: 0
Articles: 0
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.
Thx,
RKeev
This is the selection of code where it errors:
VBA:
Set Recordset = New ADODB.Recordset With Recordset ' Filter Src = "SELECT * FROM Profiles 3-4 WHERE BDE = 'HBCT' "
VBA tags courtesy of www.thecodenet.com

Local Time: 11:19 AM
Local Date: 05-23-2013
Location:

 
Reply With Quote Top
Old 04-05-2012, 11:11 AM   #2
hansup

 
Joined: Feb 2009
Posts: 447
Kb Entries: 0
Articles: 0
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.


VBA:
Src = "SELECT * FROM [Profiles 3-4] WHERE BDE = 'HBCT' "
VBA tags courtesy of www.thecodenet.com

Local Time: 09:19 AM
Local Date: 05-23-2013
Location:

 
Reply With Quote Top
Old 05-02-2012, 05:20 PM   #3
geekgirlau
 
geekgirlau's Avatar
Moderator

 
Joined: Aug 2004
Posts: 1,466
Kb Entries: 10
Articles: 0
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.
Aristotle

Local Time: 02:19 AM
Local Date: 05-24-2013
Location:

 
Reply With Quote Top
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -7. The time now is 09:19 AM.


Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Copyright © 2004 - 2012 VBA Express