run code after popup window closes

G

Guest

HI,
I have a main form with a command button that opens a popup form for entry
of data. The data that is entered in the pop is saved on the main form in a
text box. If something is entered and the popup form is closed (using a
close command button) I want to excute some code to do something special on
the main form.

I thought that the main form "got focus" event would allow me to do the code
when the popup was closed and the main for would have focus again. I've
tried every on event option that I thought might work, but none did.

Is there a way to run my code when the popup is closed and there is data my
text box on the main form. --
Phil
 
M

Marshall Barton

Phil said:
I have a main form with a command button that opens a popup form for entry
of data. The data that is entered in the pop is saved on the main form in a
text box. If something is entered and the popup form is closed (using a
close command button) I want to excute some code to do something special on
the main form.

I thought that the main form "got focus" event would allow me to do the code
when the popup was closed and the main for would have focus again. I've
tried every on event option that I thought might work, but none did.

Is there a way to run my code when the popup is closed and there is data my
text box on the main form. --


Open the popup form in dialog mode. Then the code in your
procedure will wait for the popup to close (or be made
invisible) before proceding.
 
G

Guest

Thanks Marshall,

I added "acDialog" to my DoCmd.OpenForm command, but it didn't help. My
code after the openform command still processes before the popup closes. Is
what I did correct or am I missing something?
Thanks,
 
M

Marshall Barton

Phil said:
I added "acDialog" to my DoCmd.OpenForm command, but it didn't help. My
code after the openform command still processes before the popup closes. Is
what I did correct or am I missing something?


I have never heard of that happening. Are you sure you put
acDialog in the WindowMode argument? If you have trouuble
counting commas like I do, you can use named arguments:

DoCmd.OpenForm '"formname", _
WindowMode:= acDialog, _
WhereCondition:= . . ., _
. . .
 
G

Guest

Thanks again Marshall,

I don't know why it didn't work, but I retyped the docmd line again and now
it works. You were probably right about the commas.

Maybe you can help me with another problem. On the main form (frmMain) I
have a text box called StoreHold. The popup form it is a single field
(StoreName) form asking for the name of a new store. The popup form has a
closed button which has the code:
Forms![frmMain]![StoreHold] = StoreName

When the popup closes the field StoreHold on the main form is blank. If I
enter data in StoreName before going to the popup window and place a break
point on the above code the Forms![frmMain]![StoreHold] has the info I typed
in on the main form. StoreName has the new data typed in on the popup form
but the data nevers appears on the main form. I don't understand why......
Any Help would be appreciated.
 
M

Marshall Barton

Phil said:
I don't know why it didn't work, but I retyped the docmd line again and now
it works. You were probably right about the commas.

Maybe you can help me with another problem. On the main form (frmMain) I
have a text box called StoreHold. The popup form it is a single field
(StoreName) form asking for the name of a new store. The popup form has a
closed button which has the code:
Forms![frmMain]![StoreHold] = StoreName

When the popup closes the field StoreHold on the main form is blank. If I
enter data in StoreName before going to the popup window and place a break
point on the above code the Forms![frmMain]![StoreHold] has the info I typed
in on the main form. StoreName has the new data typed in on the popup form
but the data nevers appears on the main form. I don't understand why......


I don't know. On the surface, what you have is ok. But
then, the devil hides in the details.

Maybe the frmMain is not being repainted (try adding
Forms!frmMain.Repaint). Maybe StoreName in the subform is
coming from a different record?? Maybe the mainform text
box is not named StoreHold?? Maybe this, maybe that.

I think I need more information before I make too many wild
guesses.
 

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