urgent: how to pass args to mult instance form

  • Thread starter David via AccessMonster.com
  • Start date
D

David via AccessMonster.com

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):

----
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
 
M

MacDermott

AFAIK, you can't use OpenArgs when you instantiate a form that way.
What I would do is to "pull" from the form's Open event rather than "push"
from the calling form.
Let's say you want to capture the name of the calling form:
Dim CallingForm as String
Private Sub Form_Open (Cancel as Integer)
CallingForm=Screen.ActiveForm.Name
End Sub

HTH
- Turtle
 
M

Malcolm Cook

how about defining a method on the form, Form_processTag, and call it after
setting .tag?
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Top