Refreshing textboxes after returning to an already open form (1 Viewer)

Sketchin

Registered User.
Local time
Today, 02:07
Joined
Dec 20, 2011
Messages
575
I have a form that shows project details including some financial information related to my project. In order to update the financials, or add some transactions, I click a button that opens a transactions form. On that form, I enter the data required and then close it to return to my project details form.

My question is, how can I refresh the data in the textboxes on my first form? I can't seem to figure out which event fires when I return focus to a form. I have tried On Current, On Activate and On Got Focus.

When I navigate away from the form, should I close the form and re-open it when I come back to it? (that might be a pain for the users)
 

RuralGuy

AWF VIP
Local time
Today, 03:07
Joined
Jul 2, 2005
Messages
13,826
If you open the "transaction form" as Dialog then the code behind the button waits for the next form to close or become invisible. It would be right after the OpenForm command in the button where you would run your Me.Requery.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 04:07
Joined
Feb 28, 2001
Messages
27,001
Allan's suggestion is good. The other possible event you might try is the OnEnter event, if none of those other events is doing it for you.
 

JHB

Have been here a while
Local time
Today, 10:07
Joined
Jun 17, 2012
Messages
7,732
Another way is the in event On Close in the transactions form.
 

Sketchin

Registered User.
Local time
Today, 02:07
Joined
Dec 20, 2011
Messages
575
You are a legend!

Putting it in the OnClose event will work, I just need to make sure I figure out which form I came from since there are up to 5 that the user could have came from.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 09:07
Joined
Sep 12, 2006
Messages
15,614
the simplest way is to use a wait fuinction

so either use dialog mode

Code:
docmd.openform "PopUp Form", acDialog

me.requery (or maybe)
me.refresh 0 depends what you are doing.

or have a wait function


Code:
docmd.openform "PopUp Form"
while isopen("popup error")
   doevents
wend

me.requery (or maybe)
me.refresh 0 depends what you are doing.


I prefer the second, as it lets you do other stuff during the popup - but there is no isopen() function, so you need to write your own.
 

RuralGuy

AWF VIP
Local time
Today, 03:07
Joined
Jul 2, 2005
Messages
13,826
If you use the method both Dave and I suggested then you do not need to know what form opens the transactions form! It keeps your code more modular. :)
 
Last edited:

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 09:07
Joined
Sep 12, 2006
Messages
15,614
If you use the method both Dave and I suggested then you do not need to know what form open the transactions form! It keeps your code more modular. :)

Sorry. Alan, I missed your earlier mention of a "dialog" forms.
 

Users who are viewing this thread

Top Bottom