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!

Running append query from external DB?

Status
Not open for further replies.

cgherman

Programmer
Jun 23, 2010
4
0
0
US
Can someone help? I'm simply trying to run an append query from an external DB from code in another DB.

Assume the external DB is C:\Quad_Reduction\mdb\Admin.mdb and the query in this DB is called qryTest.

Is there an easy way to do this, like with the DoCmd.OpenQuery command when you are working with a query from the current DB?

Thanks!
 
Not sure about running a query in one Access db from another Access db, but I have run code in an Access db from a VB6 app. The code, I think, may at least give you some pointers...

Dim acMyApp As Access.Application

'Create an instance of Access.
Set acMyApp = New Access.Application

'Set Access as active window.
acMyApp.Visible = True

'Open the Access database.
acMyApp.OpenCurrentDatabase "C:\Database\Test.mdb", False

'Run the TestCode() procedure within the Test.mdb database.
acMyApp.Run "TestCode"

Hope this is some help to you...
 
There are several ways. You can use automation as posted. You could link to the tables in the other database and just run the query from the first database. One of the easiest way to do this it to put your method in the external database to call the append query. Like you said using the openquery or runsql or execute commands. Ensure you setwarnings to false.

Then go to
Tools > References > Browse

in your first database, and add the external database as a reference. Then you can can call any of the external database procedures from your current database.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top