Results 1 to 7 of 7
  1. #1
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Possible to expose a form module? (Access 2002 SP-2)

    I know how to manipulate the VB_Creatable and VB_Exposed attributes of ordinary class modules in a library database by exporting them, editing them in Notepad and then re-inserting them (using Insert-->File).

    This doesn't seem to work for Access form modules. (The VB_Exposed property always gets reset to False.) Is it impossible to expose an Access form class module?

    I realize (I think) that I can create a separate ordinary (exposed) class module as a "wrapper" (if that's the right term) for the form class, but I'd prefer the direct approach if it's possible.

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Possible to expose a form module? (Access 2002 SP-2)

    What are you trying to accomplish? You can create an instance of the form and access all its public methods and properties, so there is no reason to expose the module itself with the object exposed already. If you want to provide specific behavior for a form, you do that with a class module and pass the form in to that class as an object argument. That is not at all the same thing as exposing the module of the form.
    Charlotte

  3. #3
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Possible to expose a form module? (Access 2002 SP-2)

    I don't have a direct need to make the form's module public. Instead, I'm dealing with one of my favorite VB error messages:
    <hr>Private object modules cannot be used in public object modules as parameters or return types for public procedures, as public data members, or as fields of public user defined types.<hr>
    I have a collection class that deals with the multiple instances of the form. It's the collection class that I'd ideally like to make public (it's in a library database) -- although I can admittedly work around that (I think) using a global array of the collection classes and a function in a standard module if I have to.

    The collection class includes two members that return a form instance, and at least one other member that takes a form instance as a parameter. Hence the error message (if I make the collection class public), since the form is a "private object."

    Perhaps the best solution is for me to stop trying to type the pointers to the form instances in the collection class "As Form_frmMyForm" and instead just type them "As Form". This results in incomplete IntelliSense (assuming Form_frmMyForm has one or more custom members). But if that's the only downside (it doesn't mean I'm "late binding", right?), that may be the "least bad" compromise.

    Am I missing the ideal solution?

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Possible to expose a form module? (Access 2002 SP-2)

    I'm not clear on what you're doing, but I don't see any good reason to specify the form as a particular form in your collection. It isn't the form that's private, it's the form's module, which is what you are really referencing with Form_frmMyForm. You aren't using late binding if you dim a variable as Form.
    Charlotte

  5. #5
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Possible to expose a form module? (Access 2002 SP-2)

    Thanks for the input. Assuming there's no late/early binding or other performance issue with declaring the object variables "As Form", the only "good reason" I know of to use the more particular form typing is if you've added one or more custom properties or methods to the form's class module and you want the IntelliSense list to show the custom members as well as the generic Form members. Not a big issue. Plus I suppose if I was determined to get the best of both worlds, I could use "As Form" in the declaration of each applicable procedure (both for return values and parameters) but then Dim duplicate variables of the more particular type within the procedure and point them to the same objects, use the more particular variables throughout the procedure (so I'd have complete IntelliSense), and then at the end (as necessary) reset the "As Form" pointers to the same objects as the more particular variables.

    P.S. I understand you have a lot of experience with class modules (including pre-.NET). Just in case you missed <!post=my Saturday post,454307>my Saturday post<!/post>, I'd be interested to know if you've ever encountered the strange every-other-event-sink behavior I describe there.

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Possible to expose a form module? (Access 2002 SP-2)

    As soon as you instantiated the object as a specific form, you'll have access to those additional properties through intellisense.
    Charlotte

  7. #7
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Possible to expose a form module? (Access 2002 SP-2)

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16> Thanks for the tip. For some reason it hadn't occurred to me that I could Dim an object variable (or type a function or class property) as a more general type but then instantiate it (in the Set...As New line) as a more specific type.

    For parameters, though (i.e., if I want a parameter of a property or method of a public object to be a private object), I guess I'm stuck declaring the parameter as the more general (public) type and then declaring a duplicate (more specific) internal variable in the property or method procedure to pass the object to if I want "complete" IntelliSense for the parameter object.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •