Refreshing textboxes after returning to an already open form

Sketchin

Registered User.
Local time
Yesterday, 21:52
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)
 
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.
 
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.
 
Another way is the in event On Close in the transactions form.
 
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.
 
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.
 
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:
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

Back
Top Bottom