I guess this is a simple one but I can't seem to get it to work. I want to
refresh an open form "onClose" of another.
I have a Close button on a form which has User Details on it. If I update
the data on that from, I want it to automatically refresh the details which
are shown on an open form.
I was going to use the default access code
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
DoCmd.Close
On Close I want it to update the form frmMainMenu
Can someone help me?
Thanks in advance.
forms!frmMainMenu.refresh
docmd.close acform, me.name
(Good to specify the name of the form to close to avoid problems, especially
if the focus might get shifted to the other form by the refresh command.)
hope this helps
-John
>I guess this is a simple one but I can't seem to get it to work. I want to
>refresh an open form "onClose" of another.
[quoted text clipped - 13 lines]
>
> Thanks in advance.
Hi, Scott.
It sounds like you want to requery the other form, not refresh it.
Requerying a form means that the form retrieves all records from the
database that are part of its Record Source. That includes new records,
updates and deletions.
Refreshing only refreshes the data set that the form retrieved from the
database when it was first opened or when the form was last requeried. It
won't reflect updates to the data that were carried out by other users or
other processes, such as your other form.
> I was going to use the default access code
>
> DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
That's VBA 4.0, which was deprecated a long time ago. You don't want to use
that. Use the current VBA version for your application, which is VBA 6.x,
unless you're using Access 97. Access 97 uses VBA 5.0.
> On Close I want it to update the form frmMainMenu
To requery the other form, try:
Forms("frmMainMenu").Requery
DoCmd.Close acForm, Me.Name
To refresh the other form, try:
Forms("frmMainMenu").Refresh
DoCmd.Close acForm, Me.Name
HTH.
Gunny
See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
>I guess this is a simple one but I can't seem to get it to work. I want to
>refresh an open form "onClose" of another.
[quoted text clipped - 13 lines]
>
> Thanks in advance.
scott - 28 Apr 2006 05:26 GMT
Thanks for the info. Either of the two scenarios you sent work. The only
thing is it doesn't clost the open form. Main Menu requeries, but the form
"frmRepDetails" stays open and I get an error message "Method or Data not
found.
I replaced "Me.Name" with Me.frmRepDetails" thinking it would close the
form.
Sorry, am very much a novice but appreciate your help.
> Hi, Scott.
>
[quoted text clipped - 53 lines]
>>
>> Thanks in advance.
scott - 28 Apr 2006 05:33 GMT
All good. Got it working!
Thanks guys for your time :o)
> Thanks for the info. Either of the two scenarios you sent work. The only
> thing is it doesn't clost the open form. Main Menu requeries, but the form
[quoted text clipped - 63 lines]
>>>
>>> Thanks in advance.
'69 Camaro - 28 Apr 2006 05:43 GMT
You're welcome! Glad it helped.
Gunny
See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
> All good. Got it working!
>
[quoted text clipped - 68 lines]
>>>>
>>>> Thanks in advance.
salad - 28 Apr 2006 22:55 GMT
> Thanks for the info. Either of the two scenarios you sent work. The only
> thing is it doesn't clost the open form. Main Menu requeries, but the form
[quoted text clipped - 5 lines]
>
> Sorry, am very much a novice but appreciate your help.
Sometimes it's best to close a form Explicitly. Here's probably what
you have/had
Docmd.Close
You could do this instead
Docmd.Close acForm, Me.Name