Need code or tool to read objects in one mdb and build them in another.

  • Thread starter Thread starter moondaddy
  • Start date Start date
M

moondaddy

I have a large Access 2003 application which seems to have some corruption
in it. I've tried importing everything into a new mdb but that doesn't seem
to get rid of the problems. the problem is that sometimes when I open a
class in the code environment, the application will crash. when I cant get
around this, I have to import everything into a new app. But lately, that
doesn't seem to fix it. Also, sometimes I get the error "User defined type
not defined" when I know that's not the problem. especially since all I did
is add some white space between 2 methods (it compiled before but not
after). This app is 2 years in the making with 200+ forms and 250,000+
lines of code so recreating all the forms by hand isn't a good option. I
was hoping I could find some code that would loop through all the forms and
the for each form loop though all the objects and read there properties such
as size, location, format, etc. and then use that data to create new
controls in new forms exactly like the old ones (but with out the
corruption). All the tables are linked tables to SQL server and all queries
are pass-through queries to sql server so they shouldn't be a problem to
replace. As far as the code goes, its ease to loop through all the code
behind and classes and read them into strings, and then use those strings to
create new classes in the new mdb. Where I really need help is with the
forms creation.

Can anyone help with this?

Thanks.
 
I am not aware of such a product, though from time to time, there have been
posts on similar re-creation of some particular object (esp. forms and
reports). There are many, many properties of different objects, so
signficant time and effort would be required to create such a product.

Try Compact and Repair, then copy into a new, empty database, then Compact
and Repair again.

Do you have multiple users logged in to the same front end or monolithic
database? That definitely increases the probability of corruption. And,
database cleaning is unlikely to correct the problem.

Perhaps you could use the Save As Text method for the module that you
suspect of being the problem and Load As Text into your new database. I
believe most objects have this method. First, of course, you copy everything
else into the new database.

Larry Linson
Microsoft Access MVP
 
Moondaddy,

Have you tried a decompile/recompile? This technique has resolved similar
issues for me on more than one occasion. If you have not done this before,
you can find instructions at Tony's site:

http://www.granite.ab.ca/access/decompile.htm

Remember to do a backup first.

You may have already checked for this, but I think it's also worth
mentioning that a common cause of the "User defined type not defined" error
is a missing reference. You should be able to derive the missing library by
finding the code that gets highlighted upon receiving this error once you
recompile (after the above suggested decompile).
 
Thanks I haven't heard of this before. I've done a compact/repair and
export to new mdb a zillion times but not this one. Good Tip!

--
(e-mail address removed)
MikeC said:
Moondaddy,

Have you tried a decompile/recompile? This technique has resolved similar
issues for me on more than one occasion. If you have not done this before,
you can find instructions at Tony's site:

http://www.granite.ab.ca/access/decompile.htm

Remember to do a backup first.

You may have already checked for this, but I think it's also worth
mentioning that a common cause of the "User defined type not defined" error
is a missing reference. You should be able to derive the missing library by
finding the code that gets highlighted upon receiving this error once you
recompile (after the above suggested decompile).
 
Thanks. I had a hunch it wouldn't be too easy and probably not available.
every time I run into trouble and the compact/repair cant fix it, I'll
import to a new mdb and compact/repair again. sometimes I have to do that
gyration a few times before it will start working again.

I don't have any other users on this mdb. This is my dev copy and has
always been on my box. As far as where the corruption is. I don't know.
It could be anywhere in the 200+ forms or 600+ classes (2 years ago this was
supposed to be a proof of concept project for 6 months and then re-written
in .net). This is why I wanted to recreate everything rather than
importing. Question: When you do a Save As on a form, and save it with a
different name, does Access copy it bit for bit and then simply save it with
a new name, or does it take the definition of the object with all of its
properties and re-create a new one? If this is the case then I could create
a little adding that would loop through and 'save as' all the forms with a
prefix on them, import them to a new mdb, then loop through them and remove
the prefixes.

I'll also try MikeC's suggestion by doing a decompile/recompile. I assume
that is different from a compact and repair.

Thanks for the help!


--
(e-mail address removed)
Larry Linson said:
I am not aware of such a product, though from time to time, there have been
posts on similar re-creation of some particular object (esp. forms and
reports). There are many, many properties of different objects, so
signficant time and effort would be required to create such a product.

Try Compact and Repair, then copy into a new, empty database, then Compact
and Repair again.

Do you have multiple users logged in to the same front end or monolithic
database? That definitely increases the probability of corruption. And,
database cleaning is unlikely to correct the problem.

Perhaps you could use the Save As Text method for the module that you
suspect of being the problem and Load As Text into your new database. I
believe most objects have this method. First, of course, you copy everything
else into the new database.

Larry Linson
Microsoft Access MVP



moondaddy said:
I have a large Access 2003 application which seems to have some corruption
in it. I've tried importing everything into a new mdb but that doesn't seem
to get rid of the problems. the problem is that sometimes when I open a
class in the code environment, the application will crash. when I cant get
around this, I have to import everything into a new app. But lately, that
doesn't seem to fix it. Also, sometimes I get the error "User defined type
not defined" when I know that's not the problem. especially since all I did
is add some white space between 2 methods (it compiled before but not
after). This app is 2 years in the making with 200+ forms and 250,000+
lines of code so recreating all the forms by hand isn't a good option. I
was hoping I could find some code that would loop through all the forms and
the for each form loop though all the objects and read there properties such
as size, location, format, etc. and then use that data to create new
controls in new forms exactly like the old ones (but with out the
corruption). All the tables are linked tables to SQL server and all queries
are pass-through queries to sql server so they shouldn't be a problem to
replace. As far as the code goes, its ease to loop through all the code
behind and classes and read them into strings, and then use those
strings
 
OK I tried the decompile and it seemed to really clean things up and its
much more stable now. Thanks a ton!

MS should document this more so everyone knows about it.

--
(e-mail address removed)
MikeC said:
Moondaddy,

Have you tried a decompile/recompile? This technique has resolved similar
issues for me on more than one occasion. If you have not done this before,
you can find instructions at Tony's site:

http://www.granite.ab.ca/access/decompile.htm

Remember to do a backup first.

You may have already checked for this, but I think it's also worth
mentioning that a common cause of the "User defined type not defined" error
is a missing reference. You should be able to derive the missing library by
finding the code that gets highlighted upon receiving this error once you
recompile (after the above suggested decompile).
 
I also assume that you run the production version as a mde...right?

And, of course each user gets a their OWN copy of this front end...right?

As others have mentioned, you could use the un-documented

saveastext

and

LoadFromText

The above commands actually export the forms "meta" code makes up a form,
and it is all text data.

Try typing the following and you will see this in action:

saveastext acForm,"yourFormName","c:\mydb\yourformname.txt"

You can type the above in the debug window.

Now, open up yourformname.txt...you will see the form def....

As mentioned, if your users get a mde, and you never allow multiple users
into the front end, then corruption should be very rare...

So, assuming a multi-user situation, each workstation MUST get the front
end..and that front end should be a mde...
 
Back
Top