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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

run an append query from aother database.

Status
Not open for further replies.

techkenny1

Technical User
Jan 23, 2009
182
AU
Hi all
I want to be able to run an append query from another database via a command button.
Is this possible? If it is how do we get a path on the command button so that it sees the other DB.
Many thanbks,

KP
 
dim appAccess as Access.Application
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase pathtootherdb
appaccess.docmd.openquery "nameofquery"
 
You could also use the "IN" statement in your append query (or Select, Update, etc).
This example shows appending from the table in the other database to another table in that same "other" database from the currently open database.

You could change the IN to refer to a different "other" database, or you could remove the IN for the part that you want to remain in the currently open database.

Code:
INSERT INTO tblCollegeSort ( CampusSort, CampusName ) IN 'C:\TEMP\MYOTHERDatabase.mdb'
SELECT tblCollegeSort_Bak.CampusSort, tblCollegeSort_Bak.CampusName
FROM tblCollegeSort_Bak IN 'C:\TEMP\MYOTHERDatabase.mdb'
WHERE (((tblCollegeSort_Bak.CampusSort)=1));


The nice thing about this method is there is no coding or linking required.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top