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