Code not importing with forms

  • Thread starter Thread starter JohnB
  • Start date Start date
J

JohnB

Hi.

I had a database problem today and decided to cure it by creating a new
blank mdb and then importing all objects from the corrupt mdb. There was
obviously some other problem going on (this is a rather flaky networked
environment) because at one point the import of the forms and reports took a
really long time - eg 25 minutes for each set. Anyway, when it finished, I
opened the mdb and found that none of the command button event code had
imported! The On Click events were there but apart from the Private Sub and
End Sub lines, all was empty.

I searched for the problem on this discussion group and found a similar post
from a while ago - see the second post down on this page:

http://www.microsoft.com/office/com...8ada&catlist=&dglist=&ptlist=&exp=&sloc=en-us

It seems that it couldn't be reproduced then but believe me, I've seen it.
I'm going to try to create a new mdb again tomorrow - hopefully the network
will be a bit more stable. For now, has anyone any idea why this happened?
Did I miss some option somewhere (I checked carefully, so I don't think so).

Thanks, JohnB
 
Sorry - it seems to be the second post now. It's the one called "Importing to
new database to handle...."
 
The code will not import with the form. Here is how you can do it.

Open the form in design view.
Open the form's code module.
Cut all the code in the module and paste it to a .txt file (I use word pad)
In the form's properties dialog, set the form's HasModule property to no.
Save the form. You will get a warning message, ignore it and save the form
with no code.

Open the new database.
Import the form.
Open the form in design view.
Click on the tool bar button that opens the form module. You will get a
blank moduile.
Paste the code from the .txt file into the module.
Save the form.
 
Thanks for this. Also copying the code into the clipboard and pasting it in
the imported form would work too. But that misses the point - all of the
forms that I imported had their code missing - well over 60 forms. Why would
the code not import with the form?

Anyway, I went through the process of importing all objects into a new blank
database again today and it worked fine. I've no idea why it went so
spectacularly wrong yesterday. I also found a corrupt form that may have been
at the root of the problem - when I tried to save a modification to it I got
the "Access has encountered a problem and needs to close" message - on two
consecutive occasions. So that form got deleted pronto, followed by a compact
and repair. It was probably caused by the PC I was working on yesterday
suddenly powering off (user - "oh yes, it's been doing that recently -
perhaps I should have mentioned").

Thanks again.
 
Hi.

Yes, I've just read my original post and I see that I didn't specifically
state that the problem occurred in lots of forms ( although that's what I
meant to say). I can see why you thought I meant just one. Sorry to confuse
and thanks again for the reply.
 
NP. In fact, there was an error in my response. If you import a form from
another mdb, it will import the code with it, but not if you copy/paste.
 
Back
Top