ACC2000: How to Open Multiple Instances of a Form
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q210248
ACC: How to Open Multiple Instances of a Form
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q135369
For each new instance you need an form object variable which you set using
the New keyword. Once you have the form open you can change it's
recordsource and caption.
Be careful
- the form that you are instancing must have a module (ie it can not be a
lightweight form).
- the form object variable is the best way to refer to this new instance
since you will not be able to find the form in the forms collection (unless
you know it's index).
- As soon as your object variable goes out of scope, the new instance of the
form will automatically be destroyed (and closed).
Here's some sample code that uses the selected rows in a listbox to open
multiple instances of the customer form.
Note that col is declared in the Module header so that it stay's in scope
until the current module terminates.
Dim colForms As Collection
Private Sub Command2_Click()
Dim varItem As Variant
Dim frm As Form
Set colForms = New Collection
For Each varItem In Me.List0.ItemsSelected
Set frm = New Form_Customer
frm.RecordSource = "Select * from Customer " _
& "Where Custid=" & Me.List0.ItemData(varItem)
frm.Caption = "Customer: " & Me.List0.Column(1, varItem)
colForms.Add frm
Next varItem
End Sub
--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.
How would I get it to open another instance??
Sandra Daigle said:
No, it does not open another instance. If the form is already open
the Docmd.openform merely acts like Docmd.selectobject which sets
focus to the named form.
--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.
Access 2000
Does using docmd.openform when the form is already open cause
another instance of the form?
Will resources diminish if the form is not explicitly closed before
opening it again?
The form may be opened many times and there seems to be no ill
effects: DoCmd.OpenForm "frmRolodex", acNormal, , "Name Like '*" &
gstrFind & "*'"