none
VBA: Opening one access form from another access database

    Question

  • I have to be missing something simple here.

     

    I have a large number of Access DBs I need to go through to change the fonts to Arial. I have no problem with how to do this from within the VBA code within THAT Access app.  However, copying and pasting the code into each one of them just to run it seems a bit crazy as there are so many I have to do this with.

     

    What I am doing is creating an access app (Let's call it MyDb_A.mdb) that I can browse for another access app, then running the code against the one being opened (Let's call it MyDb_B.mdb). So far, no problems with the browse functionality and opening that seperate database. Where I am having a serious problem is here:

     

    DoCmd.OpenForm frm.Name, acNormal

     

    Prior to this I have : For Each frm In dbs.allForms "dbs" is linked to the outside opened database. For example, within this loop I can print frm.name and it will give me a list of the names of the forms in MyDb_B.mdb. Perfect.

     

    However, when I try to open a form that exists in MyDb_B.mdb that DoCmd.OpenForm is thinking I am trying to open a form on MyDb_A.mdb since that is where the code is running from. Since there is no form with the same name in MyDb_A.mdb, it throws up an error.

     

    So how do I open a form in one access Db from another?

     

    Thanks in advance!

    Friday, September 19, 2008 5:22 PM

Answers