Link to home
Start Free TrialLog in
Avatar of Derek Brown
Derek BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

SaveAsText all forms or objects

I had some advice that it is a good idea to decompile a database. I have now seen elsewhere on EE that it can screw up a DB. Well it does. I now have 18 forms and 6 report all extremely complicated that will no longer import to a new database. Unfortunately as there was no indication of this corruption until I came to rename an object all of my extensive backups are also corrupt.

8 months of work trashed at the moment.

I had a useful tip that objects can be saved as text. But now as I have so many I wondered if there is a way of automating the process or even a save Project as text?

Could be wishful thinking the last bit

Derek
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

I use Decompile quite often (several times weekly), and have been doing so since it was exposed by the legendary Michael Kaplan in that 90's. I've only had one documented instance where it hosed up one of my databases, in probably more than a 1000 times.
HOWEVER ... I **always** do a quick backup prior to doing so. Select the db in Windows Explorer, Control C + Control V ...  instant backup.

So, what to do in your case? Well, in your case ... and to save yourself a LOT of time, I would contact Wayne at http://www.everythingaccess.com/accessdatabaserepair.htm .  If your db is fixable, then Wayne is the one who can fix it.

Good luck ...
mx
ASKER CERTIFIED SOLUTION
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You'd have to change that to :

strFileName = "C:\somefolder\" & frm.Name & ".bas"

Doesn't matter what the extension is.

Decompiling can certainly screw up a database, but as Joe and Dale mention it's highly unlikely.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Derek Brown

ASKER

Hi both

I have this and get error type miss match

Dim frm As Form
For Each frm In CurrentProject.AllForms
    strFileName = "C:\A\" & frm.Name & ".txt"
    Application.SaveAsText acForm, frm.Name, strFileName
Next

I cannot add file type (form or Report) as some forms are subforms
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
How do I get the immediate window to work?

The above code is on a button on one of the forms in the DB. Could this cause the problem?
Thanks Scott
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What an absurd points system

God knows who got what.

I need a calculator ans spreadsheet to allocate points. Clever!
glad we could help.
Thank you both

Fabulous.

Derek
Scott, you make it sound like you use it more frequently than that.  If so, why?
Sorry Dale, I missed this.

Many years back I created a "deployment" system that would take my development database and create a new database and move all objects over to it. I found that the SaveAsText/LoadFromText consistently gave me better results (read: no corruption) than DoCmd.CopyObject or TransferDatabase.

So I created code that cycled through the objects and saved/loaded them, transferred custom properties, etc etc.

It's not much different than what you posted, except that I use folders instead of a nameing convention to determine object type.

FWIW, I also created a utility for one of my clients who had consistent problems with corruption due to a very flaky network. Essentially, it took the techniques I described above and put them into a more user-friendly interface, and they'd just fire up that interface and create a new database as needed (frontend only). Worked pretty well for them, and I believe they're still using it to this day!
"I'm with Joe on this one, "
Just sayin' ....

And I have a question:  Did the  SaveAsText resolve your corruption issue?