apostrophe in target Db name throws error

shymdev

New member
Local time
Today, 05:25
Joined
Dec 14, 2007
Messages
4
sql = "SELECT Table1.* INTO Table1 IN '" & sExpFileName & "' FROM Table1"
CustDB.Execute sql

where the sExpFileName contains the path of The Target MS Access DB
The Query works fine. But recently I discovered that if my target File name contains apostrophe It gives error as Query Input must contain at least one table or query

Is there any way to solve this problem. Please suggest me some way
 
Not being funny, why don't you change the target name to something simple without punctuation marks?
 
fair question.. But the target Db can be created by customer.. so he can create file with any punctuation marks . I tried using double apostrophe but that also give me same error
 
You could get the target db name before you run the query and either remove any apostrophes informing the user of this via a msgbox or you could try and replace the apostrophe with a smart quote (asc 180).
 
The targetDB is created already in the path speicified in sExpFileName . This query just does the transfer of records from CustDB to target DB . Is there any way to make Access recognize it as a part of file name . I remember using double apostrophe for insertion of data with apostrophe . BUt here that also wont work.
 
Try:
sql = "SELECT Table1.* INTO Table1 IN """ & sExpFileName & """ FROM Table1"
CustDB.Execute sql
 
Alternately you can use this:

sExpFileName = db file
sExpFileName = Replace(sExpFileName, "'" "''")

thats how i get around apostrophe's without actually physically chaning them...
 

Users who are viewing this thread

Back
Top Bottom