Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting data into a different Access database using IN with variable path...?

Status
Not open for further replies.

slicendice

Programmer
Jun 28, 2002
164
0
0
GB
I have a database that I'm using to extract/generate data that includes a whole bunch of tables, queries, VBA, etc and the output of this is a set of data that will be used by a customer. The data that is extracted has to be in a separate database so that it only contains the data and nothing else.

I can do this OK using:

SQL:
INSERT INTO table_name IN 'C:\some_path\other_database.accdb'...

That's all well and good, but it hard codes the path of the other database, so I was wondering if it's in any way possible to use some kind of variable to hold the actual path of the database? So something like:

SQL:
INSERT INTO table_name IN db_path & '\other_database.accdb'...

I've had a poke around and the feeling I have is that it's not possible...which isn't the end of the world, I was just interested to see if it was possible or not.

Thanks...
 
Can you do it in VBA in code?

Something like:

Code:
Dim strSQL As String
Dim strDB As String

strDB = "C:\some_path\other_database.accdb"

strSQL = "INSERT INTO table_name IN '" & strDB & "'"

Execute strSQL [green]'DoCmd.Execute strSQL ? maybe[/green]

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top