home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

(c0ders) VBA & Access to VBA & MySQL

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 1619
Discussions: 200,925, Posts: 2,379,128, Members: 246,291
Old June 6th, 2002, 03:11 PM   Digg it!   #1 (permalink)
ph34r t3h g04t
 
Whir's Avatar
 
Join Date: Oct 2001
Location: Kingsford, MI
Posts: 19,531
Blog Entries: 7
(c0ders) VBA & Access to VBA & MySQL

Okay, this is going to sound stupid, but I'm writing this program in VBA using AccessXP. After I get it done and working, we're going to convert it to MySQL and run the database (not the program) on a Linux box we snuck into the building (just to prove how much faster it is). VBA has a coniption when I try to query using a table name with spaces. Is there a way I can keep the spaces, or do I have to remove all the spaces from my table name? Here's an example.

Code:
Public Sub Do_Aerial_Draft()
    Dim Conn As ADODB.Connection
    Dim rsPoles As ADODB.Recordset
    
    Set Conn = CreateObject("ADODB.Connection")
    Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Code Projects\Route.mdb;
     Persist Security Info=False", Admin
    
    Set rsPoles = CreateObject("ADODB.Recordset")
    
    rsPoles.Open "SELECT * FROM AerialFacilities", Conn, adOpenStatic, adLockReadOnly
    
    rsPoles.MoveFirst
    
    sTemp = rsPoles.Fields("Block Name").Value
    
    MsgBox sTemp
    
    
End Sub
Say I want it to read "SELECT * FROM Aerial Facilities", Conn, etc. Is there a way to do that? It doesn't work with " because it thinks the select statement is done right after FROM then. Would single quotes work?

Thanks,

-Whir

Edit: I should read these before I hit post...

Last edited by Whir : June 6th, 2002 at 03:14 PM.
Whir is online now   Reply With Quote
Old June 6th, 2002, 04:10 PM     #2 (permalink)
Ultimate Member
 
strangerstill's Avatar
 
Join Date: Oct 2001
Posts: 1,542
AFAIK in SQL you can put names in square brackets: "SELECT * FROM [Aerial Facilities]" - this should sort it?
strangerstill is offline   Reply With Quote
Old June 6th, 2002, 04:38 PM     #3 (permalink)
Not Really a Member
 
Join Date: Oct 2001
Posts: 25,384
strangerstill has it right, ya gotta use square brackets
I think that's standard in SQL...

I just prefer (by far!) not to use spaces in table/column names.. makes everything much cleaner.. not to mention its much easier to find bugs when you have spaces in column/table names
__________________
Helicopters don't fly; they vibrate so much and make so much noise that the earth rejects them.
vass0922 is online now   Reply With Quote
Old June 6th, 2002, 10:37 PM     #4 (permalink)
Banned
 
qball's Avatar
 
Join Date: Oct 2001
Posts: 447
Quote:
I think that's standard in SQL...

That's news to me, never saw/used that syntax before, nor can I find reference to this syntax, help a brother out? Maybe standard access SQL?

Anyway, syntax does indeed work in Access.

Syntax DOES NOT work in mySQL.

I would have figured:

"SELECT * FROM 'Aerial Facilities'";

Would work. Doesn't in Access, does in mySQL.

Access, sucks.

BTW, mySQL around 10 times faster than Access in some silly benchmarking I did.
qball is offline   Reply With Quote
Old June 6th, 2002, 10:41 PM     #5 (permalink)
Senior Member
 
Join Date: Oct 2001
Location: Hillsborough, NJ
Posts: 928
Send a message via AIM to JimG
Yes, Square Brackets [] are the answer. Use them in several queries I run at work comparing what's in one database file to another (this is such a long story, I won't explain why I do this). Anyway, if you can, it's easier not to use spaces. Even in Excel, when I'm putting titles on my columns, if I know this is going into Access or better yet some custom exe someone built, words get separated with an underscore.
JimG is offline   Reply With Quote
Old June 6th, 2002, 10:58 PM     #6 (permalink)
ph34r t3h g04t
 
Whir's Avatar
 
Join Date: Oct 2001
Location: Kingsford, MI
Posts: 19,531
Blog Entries: 7
Cool. Thanks a lot guys. I decided to cut the table and field names to no spaces, just to make life easier. Less typing and what not. I just like the spaces personally. Easier to read or something. I'm filing this one away for future reference.

-Whir
Whir is online now   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (2865)
Obama the Muslim (14)
Is the PSU I received dead? (10)
windows vista security holes (9)
Foreign voltage (10)
HIS HD5770 graphic card question (15)
Install XP pro and a Vista laptop ?.. (10)
Print spooler problem (13)
Dept. of HS: NSA 'Helped' Develop V.. (15)
A good PSU? (10)
Ideal cheap graph card for PC-Gamin.. (15)
New Computer wont recognize XP disc (7)
EVGA 9800 gtx help with finding a g.. (8)
World's largest Monopoly Game using.. (331)
Recent Discussions
Modern Warfare For the PC (33)
radeon x850xt platinum & shader 3 (3)
Have you switched yet? (84)
Install XP pro and a Vista laptop ?? (10)
Wireless Router+Cable Modems and Much.. (0)
Optical Audio A-B Switch (1)
windows vista security holes (9)
Fire in DVD (0)
The NTDVM CPU has encountered an ille.. (24)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (34)
Wireless speakers for PC? (11)
Print spooler problem (13)
Help getting around port 80 for camer.. (2)
Display shows 3x5 inch in middle of s.. (3)
monitor will not turn on at all, (1)
World's largest Monopoly Game using G.. (331)
Foreign voltage (10)
FiOS modem/router interfering with ne.. (7)
Browsers wont load websites (2)
Virus Doctor Popup? (1)
Dept. of HS: NSA 'Helped' Develop Vis.. (15)
EVGA 9800 gtx help with finding a goo.. (8)
Problem with speed step/turbo boost? (1)
Modern Warfare 2: Who Bought It? (61)
SIS 740 and Widescreen (8)


All times are GMT -4. The time now is 12:54 AM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28