Open a second instance of a form

R

Rob Nicholson

I'm opening a form using in Access 2007 using:

DoCmd.OpenForm "MyForm",,,"RecordID=100"

(The 100 actually comes from a combo)

This works fine but I want to allow the user to open *another* instance of
the form at the same time (allowing them to switch between using Windows
menu) but when a second:

DoCmd.OpenForm "MyForm",,,"RecordID=101"

is executed, the *same* form is re-used. How do you force Access to open a
new instanace of a form?

Thanks, Rob.
 
A

Al Campagna

Rob,
Given frmOne, copy that form and name it frmTwo.
Now when frmOne is open, a button on that form can open frmTwo at the
same time.
Use Ctrl-F6 to toggle between the two forms.
I did some very simple edits on both forms, (on different records) and
it appeared to work OK. You'll just have to test that for a while.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
R

Rob Nicholson

Given frmOne, copy that form and name it frmTwo.
Now when frmOne is open, a button on that form can open frmTwo at the
same time.
Use Ctrl-F6 to toggle between the two forms.

Copy as in duplicate the design? What if we need 3, 4 etc forms?

Cheers, Rob.
 
B

Brian Evans

Rob Nicholson said:
I'm opening a form using in Access 2007 using:

DoCmd.OpenForm "MyForm",,,"RecordID=100"

(The 100 actually comes from a combo)

This works fine but I want to allow the user to open *another* instance of
the form at the same time (allowing them to switch between using Windows
menu) but when a second:

DoCmd.OpenForm "MyForm",,,"RecordID=101"

is executed, the *same* form is re-used. How do you force Access to open a
new instanace of a form?

Thanks, Rob.

You can't use DoCmd and have to code it. Search around for articles
on "How to Open Multiple Instances of a Form in Access"

Brian
 
A

Allen Browne

It's easy enough to get a 2nd instance of a form with the New keyword.
What's more interesting is how to manage the instances correctly, as they
all have the same name and you need to manage the lifetime of the variable
for each instance.

See:
Managing Multiple Instances of a Form
at:
http://allenbrowne.com/ser-35.html
It manages the instances with a custom collection that's based on the hWnd
of each one. Download the sample database to see how it works.
 
R

Rob Nicholson

You can't use DoCmd and have to code it. Search around for articles
on "How to Open Multiple Instances of a Form in Access"

Thanks - you are a gent! More complex though than I expected...

Cheers, Rob.
 
R

Rob Nicholson

http://allenbrowne.com/ser-35.html

Thanks for this. That works to get multiple windows. Maybe you can how help
me with implementing the "Where" bit of the DoOpenCmd - that RecordID=101
bit.

I must admit that whilst I've very familar with ADO recordsets (from use in
VB6), I've always been a bit vague in how Access binds to the recordset.

When using DoCmd method, the Where parameter is actually "[SystemID]=56"
which selects a specific record in the recordset. It appears that the
form/recordset is bound to the "Systems" table.

How, after manually creating the instance, do I select a specific record.

Does the Where bit of DoCmd actually modify the recordset query and only
return one record or is it opening all records and then filtering out
everything else.

I've tried Form.Recordset.Filter="SystemID=56" but that doesn't make any
difference.

BTW - what is the type of the recordset returned by Form.Recordset? It's not
ADODB.Recordset.

Thanks, Rob.
 
R

Rob Nicholson

I've tried Form.Recordset.Filter="SystemID=56" but that doesn't make any
difference.

Sorted it - created another recordset after opening the form and did set
Form.Recordset = NewRecordset

Cheers, Rob.
 

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

Similar Threads


Top