[AccessD] Instantiate Forms as Objects

Ken Ismert KIsmert at TexasSystems.com
Tue Jan 20 10:32:46 CST 2004


Hello Group:

As you know, you can instantiate an Access form, just like any other object,
by using its class name:
    Dim rFrm as Access.Form
    Set rFrm = New Form_YourForm	' form 'YourForm'

This syntax allows you to create multiple open instances of a form, a
necessity for my framework. However, I've run into a problem.

What I need is a simple, one-line way to instantiate a form object using a
string:
    sFormName = "YourForm"
    Set rFrm = MFOS("Form_" & sFormName)  ' MFOS = "Magic Function or
Syntax"

Note: Because of the multiple instance requirement, DoCmd.OpenForm won't
work. It can only make one instance of a form.

I can't find a CreateObject syntax that works. In my current function, I use
a big Case statement matching the form name to it's class. This has become a
pain, because every time I add or remove forms, I have to edit the function.

Have any of you found a way to do that?

-Ken



More information about the AccessD mailing list