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

    Question Unanswered: urgent: how to pass args to mult instance form

    Need help fast!...

    How can I pass the equivalent of an OpenArgs value to a multiple-instance form when adding it to a collection?

    Here is the code used to add the form to the collection (to create the newest instance of the form):

    Code:
    Private mcolContactDetailForms As New Collection
    
    Private Sub Combo0_AfterUpdate()
    Dim frmDet As Access.Form
    Static d As Long
    d = d + 1
    Set frmDet = New Form_frmContactDetails
    With frmDet
      .Caption = "Contact Details " & d
      .Visible = True
      .Filter = "pkautContactID = " & Me.Combo0
      .FilterOn = True
      .Tag = "Forms!frmContactLookup!Combo0|Det"
    End With
    mcolNewContactForms.Add frmDet, frmDet.Caption
    End Sub
    I'm no expert on this procedure...it was adapted from an ACCESS ADVISOR article (www.msaccessadvisor.com, "Create Multiple Copies of a Form").

    What I need to do is have the value that I put in the Tag used in the Open event of the form. However, none of the properties set here are put into effect on the form until after it is Opened, Loaded, Activated, etc. And you can't set the OpenArgs value here because it is read-only.

    So, how can I pass a string to the new form for use on its Open event?

    Thanks in advance!
    David

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    dunno about the solution you are requesting
    another way round it is to open the new form, then push or pull the required information from the calling or called form

    eg

    forms!calledform!controlname=me.controlname 'set controls in calling form
    OR
    me.controlname=forms!callingform!controlname 'set controls in called / child form

  3. #3
    Join Date
    Jul 2004
    Posts
    67

    Unhappy

    Maybe...here's the explanation...

    I have a form that I use for several purposes (rather than having numerous copies of the same form). Certain controls are visible/not visible depending upon the calling form (or more precisely, the purpose of the call). The form is not simply opened, a new instance of the form is spawned. So, I would like to pass info to the form when it is spawned so that it can set the appropriate properties.

    For similar forms that do not require multiple instances, I simply pass the info in OpenArgs and process the OpenArgs on the form Open event. How can I perform a similar action on a form that is spawned as a new instance in a collection?

    Pushing or pulling the info after the form is opened is not so great...because I am not setting control values, but rather properties of the form. So the user would see the form open with a header and footer (for example), then load a record, then see the header and footer disappear.

    I could use global variables, but I thought there might be a more direct method of passing the info (specifically, a string).

    Thanks,
    David

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    if your code to do the pulling is in the forms load event then the user will not see anything except that which you want. IE perform you set in the forms on load event
    you can reference any public variables and controls from another form
    so you cna determine the version of the form you want to show based on a setting within the calling from, and populate the called form as required

Posting Permissions

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