SQL Syntax

Peter Bellamy

Registered User.
Local time
Today, 21:14
Joined
Dec 3, 2005
Messages
295
Can someone please advise the way to include the quotes for a path in a SELECT INTO IN FROM statement.
The following does not seem to like the path section?

Code:
StrSQL = "SELECT Parts.* INTO [Parts Old] IN 'Z:\Database\2000\Service2k.mbd' FROM Parts;"

Cheers
 
Check out this it talks about how to make sql read as quotes, or string, etc. I THINK that you need to separate your SQL with something like:

Code:
StrSQL = "SELECT Parts.* INTO [Parts Old] IN" & " Whatever the correct way to do the SQL here. " & " FROM Parts;"
 
It has been while since I have done it, but I believe you put double quotes where you want one.

StrSQL = "SELECT Parts.* INTO [Parts Old] IN ''Z:\Database\2000\Service2k.mbd'' FROM Parts;"
 
Thanks.
I had tried the " & " path " & " solution but it does not leave the path in quotes which I assume it has to have.
 
I haven't but it is the same as alternating quotes.
" & Chr(34) & Text & Chr(34) & " the same as " ' Text ' "

Which I have tried
 
Do you get any errors at all? Can you post the code which uses the new sentax?
 
Thanks for sticking with this!
The error is :
Could not find file 'Z:\Database\2000\Service2k.mbd'

A debug.print of the SQL before the SQL is actioned is:
Code:
SELECT Parts.* INTO [Parts Old] IN 'Z:\Database\2000\Service2k.mbd' FROM Parts;

Which makes me think the single quotes are not allowing the path to be read as a text string.

There is just one other possibility. I am developing this on a PC at home, not at work. I have set up a network drive as z: with the correct folders and file. Perhaps it does not work exactly like it would on a 'proper' network?

I will simplfy the path top the local HDD and see if that works.

Cheers
 
You don't need quotes and the extension is incorrect, it's mdb not mbd. Try one of:
Code:
StrSQL = "SELECT Parts.* INTO [Parts Old] IN Z:\Database\2000\Service2k.mdb FROM Parts;"

StrSQL = "SELECT Parts.* INTO [Parts Old] IN Service2k.mdb FROM Parts;"
 
Dyslexia rule, KO !!
Correcting that and using no quotes gives an error on the line:
Code:
SELECT Parts.* INTO [Parts Old] IN Z:\Database\2000\Service2k.mdb FROM Parts;

of
Query input must contain at least one table or query
 

Users who are viewing this thread

Back
Top Bottom