how to export Access 2010 data macros

后端 未结 5 1448
醉酒成梦
醉酒成梦 2020-12-06 06:54

I need to transfer Access data macros from my test db to my production db. Anybody know how to do that?

I know that transferring tables from one accdb to another wi

5条回答
  •  离开以前
    2020-12-06 07:49

    To expand on Martijn Pieters' / Lanik's answer (thanks Martijn and Lanik), I had a need to create virtually the same data macros on 28 different tables, with an AfterInsert, AfterUpdate, AfterDelete, and named data macro on each. So, I used the SaveAsText command

    SaveAsText acTableDataMacro, "TableName", "C:\PathToFile\DataMacro.xml"

    to create a template, then used that template to create the 28 xml files via a little vba code, substituting the table names, primary keys, etc. I also created 28 LoadFromText commands. I could then use the LoadFromText commands to load all the macros at once, with a repeatable process. Now that I am done testing, I can quickly update the production database this way or add the same data macros to other tables easily.

    So others know, LoadFromText overwrites any previous macros, which is terrific since I didn't have my template correct on the first try.

    Given the above, the next step is to have your 'updater' database application use a DoCmd.TransferDatabase command to transfer the module with a function/sub with all the LoadFromText commands to the Data .accdb. It should also transfer a macro to run the function/sub. I tried having my updater then execute the macro to load the data macros, but Access security prevented that. so, you may need to get your user to open the database and Enable it, then run the macro. This is more convoluted then if we could edit the data macros directly, but does provide a workaround that solves the problem.

提交回复
热议问题