Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Corrupt VBA code module

Status
Not open for further replies.

sweenea

Programmer
Dec 20, 2006
2
US
I have a project that has a problem with the custom VBA code I wrote. Access won't open the report and wants to
delete the VBA code. I want to save a copy of the VBA source, since most of it is good and has been checked out.

Is there a way to access a copy the VBA source code in a MS Access project, independant of opening it in MS Access?

Thanks in advance
Art



 
There are methods that might work.

Sometimes, you can be so lucky as to enter the design view of the report, then enter it's module, but probably that wont be available.

Then, from VBE, you might doubleclick the report in the project explorer (ctrl+r), which might give you access to copy the textual representation of the code.

One method that might work, is creating a new db, and from File | Get External Data | Import (in a2k7, it's the External Data tab | Access button) import the objects from the corrupted db. Again this might work.

If you can enter the database, then there's also the not so well documented methods .SaveAsText and .LoadFromText of the application object, syntax (you can run it from the immediate window (ctrl+g))

[tt]application.saveastext acreport, "<name of report>", "c:\reportname.txt"
' then fetch it - in another db - with
application.loadfromtext acreport, "<name of report>", "c:\reportname.txt"[/tt]

There are some writeups of code to do this for all objects in a database, except for the tables if you search.

Then, one can also try the /decompile option. See for a detailed instruction. In stead of doing the shortcut thingie, you might also just open while holding the Shift key (to avoid running code), also note that between step 2 and 3, exit the database (and all instance of Access), then reopen while holding Shift key to do the compact - this is to flush out all corrupted items that might not be entirely gone if compacting immediately after a /decompile.

Roy-Vidar
 
Thanks for the suggestions. Unfortunately I still can not recover the source. I guess sometimes you just lose them.

art
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top