Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2004
    Posts
    67

    Question Unanswered: How to refer to a form instance

    I'm sure this is simple, but I can't find it anywhere...

    How do I refer to an instance of a form using its key value?

    For example, I have a collection 'colForms' and two forms in that collection with the keys 'Key1' and 'Key2'. How do I refer to the instance that has Key1 in code (for exampe, to close or requery the Key1 instance of the form from another form)?

    Thanks in advance,
    David
    dminstance

  2. #2
    Join Date
    Feb 2005
    Posts
    6
    I believe it would be something like:
    colForms("Key1").Requery

    To close the form just remove it from the collection and it will close:
    colForms.Remove "Key1"

    Unless a variable somewhere else was set to reference that form. When the last reference is removed then the form will go out of scope and close.

  3. #3
    Join Date
    Jul 2004
    Posts
    67
    I thought the same thing. But that brings an 'Invalid procedure call or argument' error

  4. #4
    Join Date
    Feb 2005
    Posts
    6
    Could you post the code here for where you add the form to the collection. Also post the code for what gives that error.

  5. #5
    Join Date
    Jul 2004
    Posts
    67

    Red face Praise caffeine, I've got it!

    After a week, I've figured this out.

    The syntax is correct. The problem was that the code that was indexing the form instances was not in sync with the code that was referencing the instance.

    So, I was referencing "Contact Details 2" while the count was on a different number, such as "Contact Details 3". That's why the collection's argument didn't exist.

    What's the protocol for finally figuring something out that was so stupid - glee or depression?

    Thanks for time,
    David

  6. #6
    Join Date
    Feb 2005
    Posts
    6
    I would say to pat yourself on the back and go home for the weekend

Posting Permissions

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