Setting a subform to a member of a collection

Discussion in 'Access VBA Modules' started by Dennis Snelgrove, Jun 2, 2010.

  1. I'm attempting to write a class module that will act as a multiple
    subform manager.
    I've got a form in Access 2007 which has a large empty subform
    container, a list box, and a set of command buttons for opening up a
    couple of types of subforms and doing a couple of other things. The
    subform is simply a holder for the currently active form; in no case
    is there any need for a parent/child relationship. The idea is that
    this database is an event log and we have a couple of different
    subforms that we use to record different types of events during a work
    shift. I need to be able to open up more than one entry at the same
    time as there are times when we have more than one event happening
    concurrently. I want the manager to use the listbox to show the
    currently open entries; click on an entry in the list box and it
    brings (or switches) that form into the subform container, while not
    closing any other subform that may still be open. All subforms have a
    "Save" button on them for saving the individual entry.

    In the General Declarations area of the class module, I declare :
    Dim clnOpenSubForms As New Collection
    Private lstOpenSubForms As ListBox
    Private chldSubFormContainer As SubForm

    I store a form in clnOpenSubForms with a key of "CStr(hWnd)" The list
    box and the subform are properties of the class, telling it what
    control to use on the form. My problem is that I can't figure out how
    to set the chldSubFormContainer to an entry in the collection. I know
    I'd do this in the list box update event procedure, but how to do is
    where I'm confused.

    Any help is appreciated...
     
    Dennis Snelgrove, Jun 2, 2010
    #1
    1. Advertisements

  2. Dennis Snelgrove

    Alex Dybenko Guest

    Hi,
    as I understand you - try:

    strKey=CStr(hWnd) ' set the key to appropriate value

    Set chldSubFormContainer = clnOpenSubForms(strKey)

    --
    Best regards,
    ___________
    Alex Dybenko (MVP)
    http://accessblog.net
    http://www.PointLtd.com
     
    Alex Dybenko, Jun 2, 2010
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.