how do I run an event on a form that spawns a popup after pop isclosed?

B

bobg.hahc

access 2k;

I've read a million "why doesn't on focus / activate work". I'm very
well aware that on focus doesn't work as most expect.

Here's what I don't understand:
when my form does an openform to open a "pop-up form - that is NOT a
'popup' ", it NEVER EVER runs the deactivate code.

Now - I don't really care about the deactivate code - I REALLY want to
activate code to run.
but if the original form is never "deactivated" when another form is
open from the "on open" of the original; then my original will NEVER
be activated when the popup is closed!!!!

Simply:
When my form opens, it should cause a popup; the user selects a value,
and the popup closes.
There is a "title" field on my form that should be populated with a
global value from the popup window.

How do I tell access to WAIT to populate this field until AFTER the
popup is closed??
(or refresh it after the popup is closed)

AND - I cannot have code in the popup itself assigning the value,
because the popup is called from MANY forms, and it won't know which
form to use to assign values.

TIA -Bob
 
J

John W. Vinson

Simply:
When my form opens, it should cause a popup; the user selects a value,
and the popup closes.
There is a "title" field on my form that should be populated with a
global value from the popup window.

How do I tell access to WAIT to populate this field until AFTER the
popup is closed??
(or refresh it after the popup is closed)

One handy way to do this is to use a trick with Dialog mode. If you open the
popup form with WindowMode := acDialog in the OpenForm method, it will pause
the code in your calling form until the popup form is closed OR until its
Visible property is set to False.

So you can have the "close" button on the popup form simply set the form's
Visible property to False, rather than closing it. In the calling routine you
can then retrieve the value and close the (now invisible) form.

DoCmd.OpenForm "MyPopupForm", WindowMode := acDialog
Me!targetcontrol = Forms!MyPopupForm!controlname
DoCmd.Close acDataForm, "MyPopupForm"
 
B

bobg.hahc

One handy way to do this is to use a trick with Dialog mode. If you open the
popup form with WindowMode := acDialog in the OpenForm method, it will pause
the code in your calling form until the popup form is closed OR until its
Visible property is set to False.

So you can have the "close" button on the popup form simply set the form's
Visible property to False, rather than closing it. In the calling routine you
can then retrieve the value and close the (now invisible) form.

DoCmd.OpenForm "MyPopupForm", WindowMode := acDialog
Me!targetcontrol = Forms!MyPopupForm!controlname
DoCmd.Close acDataForm, "MyPopupForm"

John -

TX SO much for your reply...
I never knew about the window mode property... 1 of the little things
that slipped by I guess :)

This is EXACTLY what I want - to be able to suspend code execution !!
(I wonder - is there a way to do this without using a form's window
mode? ie: could I stop code execution until an event trigers
continuation ? )

I am curious though -
Even when I use the dialog window mode in the form's on open; I notice
that a control box which is equal to a user function (ie: text box
source = fGetMyValue() ) is still executed PRIOR to completion of
the on open code.

Now - this is easily worked around by un-binding the control, and
assigning it in the on open code - so it's not really a big problem.
BUT - one would certainly expect that the acdialog which halts code
execution would prevent the control's code from being executed in
addition to any other code.

TX again, John!
Bob
 
B

bobg.hahc

Even when I use the dialog window mode in the form's on open; I notice
that a control box which is equal to a user function (ie: text box
source = fGetMyValue() ) is still executed PRIOR to completion of
the on open code.

Now - this is easily worked around by un-binding the control, and
assigning it in the on open code - so it's not really a big problem.
BUT - one would certainly expect that the acdialog which halts code
execution would prevent the control's code from being executed in
addition to any other code.

TX again, John!
Bob

Adden:
I've now done just what I described; but the field's value is not
displayed correctly - even after a "me.refresh".

Is there something special I have to do to get a field to display it's
correct CURRENT value?


TIA (again :)
Bob
 
J

John W. Vinson

I am curious though -
Even when I use the dialog window mode in the form's on open; I notice
that a control box which is equal to a user function (ie: text box
source = fGetMyValue() ) is still executed PRIOR to completion of
the on open code.

Now - this is easily worked around by un-binding the control, and
assigning it in the on open code - so it's not really a big problem.
BUT - one would certainly expect that the acdialog which halts code
execution would prevent the control's code from being executed in
addition to any other code.

It suspends the code in the *CALLING* form's module; any code in the *CALLED*
form will of course execute as normal. Maybe you need to use the form's Load
event, which executes after the connection to the recordsource has been made.
 
J

John W. Vinson

Adden:
I've now done just what I described; but the field's value is not
displayed correctly - even after a "me.refresh".

Is there something special I have to do to get a field to display it's
correct CURRENT value?

Shouldn't. Please post your code, and the names and control sources of the
relevant form controls.
 

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

Help needed with Popup Form 1
Close Popup form when it looses focus 8
Form Not Closing 1
OnGotFocus on a popup form 7
Popup Form 1
form size on openform 4
How can I refresh my table data? 2
Form Corruption 2

Top