Open the same form two times

  • Thread starter Thread starter nieurig
  • Start date Start date
N

nieurig

Hello forum,
this question would aswered in the past, but i dont find
this answer.

I need to open the same form two times at Access 97.
If I call:

' Open the 1. form
DoCmd.OpenForm "F_MyForm"
' Open the 2. form
DoCmd.OpenForm "F_MyForm"

Access activate the first form instead of creating a new
form.

If i call:

Dim frm As Form
Set frm = New Form_F_MyForm
frm.Visible = True

i see the second form creating, but it don't stay at the
screen.

How to solve this problem?
Thanks in advance for any help.

Niels
 
When you say the second form doesn't stay at the screen, do you mean it goes
behind the other form? If you want to see both forms at the same time and be
able to interact with them on the screen, you'll need to restore the forms
(if maximized, only one form will fill the screen at one time).

More info, please.
 
Hi Ken,
thanks for your answer.
When you say the second form doesn't
stay at the screen, do you mean it goes
behind the other form?
No, it looks like hiding the form after construction.

If you want to see both forms at the same time and be
able to interact with them on the screen,
Yes, this is what i wont.
you'll need to restore the forms
How i have to "restore" the forms?

Niels
 
Restore means that the windows are not maximized and they're not minimized.
The windows are of a size that is smaller than the screen. You know that a
window is in Restore mode when the second button from right at top of the
window is a rectangular screen, not two overlapping screens.

You must put this code line
DoCmd.Restore

in your code right after your DoCmd.OpenForm to open the second form.
 
Why would you EVER want to open two instances of the SAME
Form?!?

Would making two DIFFERENTLY NAMED forms do the job? Make
a copy of your form and name them with a 1 and a 2 at
their ends. (ie. fShipping1 and fShipping2). You can
also synchronize them so they will both update when one is
modified.

I guess MY question is "What exactly are you trying to do?"

email me if you need to.
 
KEN: >If you want to see both forms at the same time and be
able to interact with them on the screen,

NIEURIG: Yes, this is what i wont.

How about embedding the form that you want into different form shells, then
calling up the different shells?

Regards,
Al
 
Generally, I agree... but there are occasional instances when 2 or more
instances of the same form is needed.

In one instance I had to have the same form showing twice- I'm a physician
and on the HICF form (the one I use to set up the billing information) there
are 2 insurance information fields (primary and secondary insurance forms).
I have both forms showing at the same time- one linked to the Insurance1
information and the other to the Insurance2 information. They both share the
same underlying insurance lookup information, but end up populating
different insurance fields.

In another instance I added to my scheduler routine a "week at a glance"
using 7 instances of the same form inside one form capsule to show the seven
dates. It was hard to set up, but it worked!

In both instances I embedded the similar subforms on the same form. In the
first sample, I would make them visible/invisible to make them appear to
float over the form when called up.

Anyone interested in my scheduler form, let me know and I'll upload it to my
Yahoo Briefcase (http://f1.pg.briefcase.yahoo.com/bc/alborgmd ).
Regards,
Al
 
Hi all,
at first, thanks to all for the comments.
I spend my weekend far from any computer ....
Why would you EVER want to open two instances of the SAME
Form?!?
1. I like to display to different records of a table at
the same screen.

2. The User can change the behaivoir and view of the form.
(Set a filter, select records ...) To present a other kind
of recordset (but in the same style) i need a second
instance of the form.


My problem was't solved, because
docmd.restore

dosn't work (like i need it to work)

If I create 2 or more instances by
Dim frm As Form
Set frm = New Form_F_MyForm
frm.Visible = True

the second form stay on screen if frm was created as
a "global" variable f. If f was local, the form was shown
and destroyed.

Any ideas?
Niels
 
You problem is likely that your code sub routine is going out of scope.

When you declare variables in a sub, when that sub ends, all variables used
in the sub are thrown out. (that makes sense, since other wise each time you
run a sub, all kinds of variables and junk would still be sitting
around...it would be a night mare!).

Hence,

Sub MyTest

dim f1 as f_MyForm

f1.Visiable = True


End Sub

when you reach end sub, the variable f1 that holds the form is going to be
gone (or what we call out of scope). Thus, the form will flash, but when the
sub ends, the form will close since the f1 var no longer exists. What this
means is that you need to declare the variables at a module level, and NOT
at a form module level. (actually, you can declare the vars at a form level
model, and then if you close the form, then ALL child forms that you opened
with the form will close for you!...so this can be a real cool effect!).

Either move the variable declare to a module, or at least move the variable
out of the short sub, and into the form level module, or module level.
 
Back
Top