
Exporting a form design with code to another .mdb
Quote:
> In order to only copy over a form that I either improved
> or added, I tried to export the form rather than the
> rigmarole involved with of importing tables and then
> overwriting the "user" database. From the VB code window
> I select the form from the Project explorer pane and
> use "export file" option to save the form to disk as
> a .cls type then import the saved .cls module into
> the "User Copy" databse. This brings over the code but
> not the form and if a form with the same name already
> exists, that form is rendered inaccessible!
That's not the right way to do it. The VB Project Explorer only knows
about code modules. The forms listed there are class objects, and can
only be exported as class modules from the VB window, because that's
all VB interface knows about them (and you'll notice that only forms
with code modules show up there -- "lightweight" forms aren't seen
because they have no associated class modules). When you export the
form's class module from the VB window, what you get is a .cls file
that is the text definition of the class. There are none of the
form's controls and properties, because they aren't part of the class.
Think of it this way: the form's class module is one of many things
that belong to the form. The module doesn't contain the form; the
form contains the module. If you export the module, that's all you
get -- not the form and all the other things it owns.
Quote:
> What I was wondering is how would one export only a form
> and it's code to another database so it's useable in it's
> entirety?
Either export it directly to the other database from the Access
application window, *not* the VB window, as I described before, or ...
Open the other database and (in the application window) import the
form from the database containing the modified version, or ...
Use the undocumented Application.SaveAsText method to save the
definition of the form and all its objects including the module to a
text file, and then go to the target database and use the undocumented
Application.LoadFromText method to load the form from the text file.
But it's much simpler to just export the form in the normal manner
supported by the user interface.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
Quote:
> >-----Original Message-----
> >> Is there a way to export a form designed in one .mdb to
> >> another .mdb? I tried the export feature but the form
> is
> >> exported as a .cls module with all the vba code but the
> >> form design itself is not accessible...
> >In code you could use DoCmd.TransferDatabase -- see the
> help file for
> >details. Via the user interface, you'd select the form
> in the
> >database window, click menu items File -> Export..., and
> select the
> >database you want to export it into. It works fine for
> me. What did
> >you do that resulted in a .cls module?
> >--
> >Dirk Goldgar, MS Access MVP
> >www.datagnostics.com
> >(please reply to the newsgroup)
> >.