Thursday, January 05, 2012

Backup and recover queries, forms, reports and modules to/from text

A Microsoft Access database is a complex object that is subjected to much stress in network environments and by programming. As a result you need backups of your work. In this article I will show you the

Application.SaveAsText  and Application.LoadFromText methods

to save and then recover queries, forms, reports, macros and modules. To do this you will export all objects to text files in a sub folder using code that I will provide you.  Then you copy and paste some vba code that will be autogenerated and use that to populate an empty database with all your newly exported objects.

This whole process can also help you diagnose and sometimes help you recover an already corrupted database.

It will take you less than a quarter of an hour once you get the hang of it. Read the article here

A Happy New Year to all of you.

Garry Robinson
MS Access MVP 2006 - 2012


pacomegia said...

your "Read the article" link points to this page, not to the article said...

terrific tool, and very kind of you to make it available. i really need it and can't wait ... please check the link to the article that is on your blog -- it may not be correct. thanks!

Freaky JellyFish said...

I beleive that the link everyone is looking for is this article that has been posted to the website.

Exporting and Recovering Programming Objects


Freaky JellyFish said...

BTW, you can get to the article by clicking the Title of this blog entry ("Backup and recover queries, forms, reports and modules to/from text").

I would suggest a small change to the excellent example you have here...
Not all users follow proper File Naming conventions when naming Access Objects. Access allows you to use characters in object names that are not allowed in file names (e.g. ">", "<"). It would be nice if you "translated" invalid characters to prevent a failure from the lines " objName = dbs.QueryDefs(i).Name" or "FilePath = folderPath & doc.Name & ...".

Thanks again for the excellent example on using these undocumented commands.


spijk said...

You mention that "this example will work well with the exporting of all tables to text example described earlier in this chapter". Can anyone point me in the right direction to find this?