Parameter for Database in a make table querie

B

BD

It's possible to use a parameter at IN clause that take the name of a
database in a make table query that can be reused in the same front
end for different back end databases? Like this:

INSERT INTO table
IN Param ...

In code:

dim db as database
dim qdf as querydef

set db=currentdb
set qdf=db.querydefs("qryname")
qdf("Param")="c:\mydatabase"
db.execute dbfailonerror

I have a error that can't use database type. How can I resolve this?


[]'s
BD
 
A

Allen Browne

I doubt you can use a parameter like that.

But it's dead easy to build the string in your code. In the following
example, strcStub is the entire SQL statement up to and including the IN,
and strcTail is the rest of the SQL statement after the file name:

Dim strFileName As String
Dim strSql As String
Const strcStub = "INSERT INTO ...
Const strcTail = " WHERE ...

strFileName = "C:\MyFolder\MyFile.mdb"

strsql = strcStub & strFileName & strcTail
Debug.Print strSql
db.Execute strSql, dbFailOnError
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top