Hi,
I'm creating an auto-update program for MS Access, the idea is that you add all objects to one database, we'll call it "Updater.mdb", and then you open "updater.mdb". It will then connect to another database, we'll call it "program.mdb", and copy all database objects.
This is easy to do, but the catch is that if the object already exists, then I want to rename the object before copying, i.e. if "report" already exists, I'll rename it to "report1" and then copy report.
I've had a lot of problems renaming objects in a foreign database. I tried using the documents.properties("name") property, but that seems to be read-only. It seems like the ONLY way to do it is to use docmd. So, I tried that: I used automation to create a new application and connect to my target database, and used docmd to rename the objects. This may work - I ran into one problem here but I think I can overcome it - but then my code to copy the object no longer works, since the database is opened by another process.
Bottom line: I guess I could close and re-open the databases for every name change/copy pair, but that seems like a hack and scares me a bit, plus I wouldn't want users seeing the database close and open repeatedly, plus suppose that I have several hundred of these, that starts to get pretty crazy.... Is there a better way? I really wish there was a way to rename a database object (report, form, macro, etc.) without having to use Application.docmd... Is there some way that I don't know of? If there is a way to do it inside DAO.database, - or maybe even with another object model? - then I'm golden. Otherwise, I'm screwed
Jason
I'm creating an auto-update program for MS Access, the idea is that you add all objects to one database, we'll call it "Updater.mdb", and then you open "updater.mdb". It will then connect to another database, we'll call it "program.mdb", and copy all database objects.
This is easy to do, but the catch is that if the object already exists, then I want to rename the object before copying, i.e. if "report" already exists, I'll rename it to "report1" and then copy report.
I've had a lot of problems renaming objects in a foreign database. I tried using the documents.properties("name") property, but that seems to be read-only. It seems like the ONLY way to do it is to use docmd. So, I tried that: I used automation to create a new application and connect to my target database, and used docmd to rename the objects. This may work - I ran into one problem here but I think I can overcome it - but then my code to copy the object no longer works, since the database is opened by another process.
Bottom line: I guess I could close and re-open the databases for every name change/copy pair, but that seems like a hack and scares me a bit, plus I wouldn't want users seeing the database close and open repeatedly, plus suppose that I have several hundred of these, that starts to get pretty crazy.... Is there a better way? I really wish there was a way to rename a database object (report, form, macro, etc.) without having to use Application.docmd... Is there some way that I don't know of? If there is a way to do it inside DAO.database, - or maybe even with another object model? - then I'm golden. Otherwise, I'm screwed
Jason