I’m trying to understand how to use the CopyObject method. I have successfully used this method to copy a table and give it a new name in the same database. But I need to copy a table from a different database into the database I am working with -- that's where I stumble.
When working in Animals.accdb, this line of code in the load event of a form works as expected, making a copy of tblDomesticated and renaming it:
Code:
DoCmd.CopyObject , "tblDomesticatedCopy", acTable, “tblDomesticated”
When working from another database, the same line of code in a form load event produces run-time error 7874: Microsoft Access cant’ find the object ‘tblDomesticated’. Not surprising.
When working in a different database, I tried this line of code to copy a table from Animals.accdb, but I get run-time error 2465: Microsoft Access can't find the field '|1' referred to in your expression. An internet search turns up a lot of users with this error but no clear explanation of what it is.
Code:
DoCmd.CopyObject , "tblDomesticatedCopy", acTable, [C:\Stuff\Animals.accdb].[tblDomesticated]
So one question I’d appreciate some help with is does the CopyObject method support copying an object (a table in this case) from one Access database to another? If so, how does one reference the object in the “other” database?
Thanks.