Form refresh

JoseL

Registered User.
Local time
Tomorrow, 00:39
Joined
Apr 21, 2008
Messages
11
I have a form (let's say Main) which has a button that opens another form to add data.
When I close this second form I want the Main one to display the new data. But it doesn't unless I close and open it again.
I have tryed the docmd.requery and to unload and load the form again by itself, but I didn't get any success.

Thanks again for your help.
 
Me.Requery should do the trick tho...

Add "Me.Requery" to the code that opens the form
 
Thanks Mailman,

I have added the Me.Requery at the Main form On Activate event and now it works perfect.

Thanks again.
 
On activate might not be the "perfect" place to put it... but as long as it gets the proper result :)
 
The ACTUAL place that would be proper to put the requery would be EITHER:

1. As Namliam has suggested - in the code on the form that opens the other form to add the data. However, for it to work you would need to open that other form as DIALOG in order to suspend the code on form A until Form B is closed. To open B as dialog, you would use

DoCmd.OpenForm "FormB", , , , , acDialog
Me.Requery

2. You could do it in the Form B Close event:

Forms!FormA.Requery
 
I have placed it at the Form B close event. It works fine.

And.....I don't want to abuse of you both (if so let me know), but why is not a good place On Activate?

Many thanks.
 
Put a little code in the On activate event:
Msgbox "Hello"
or something ... and you will find out....

Point beeing it is triggered everytime the form is activated... i.e. if a user clicks away for a sec and comes back it will trigger too.... something you probably (definatly!) dont want, in particular if your DB starts growing and "requery" times go up.
 
And.....I don't want to abuse of you both (if so let me know),
Actually, no problem...We like to be able to explain how/why something works as that will help you in the future instead of being dependent on someone else to give you answers, you'll know the what/why of something and that can help you look up answers to other questions.

So, that is actually a good thing.
 

Users who are viewing this thread

Back
Top Bottom