Use one form to update another...possible??

theKruser

Registered User.
Local time
Today, 01:59
Joined
Aug 6, 2008
Messages
122
I am trying to refresh one form from another.

I have a table (tblZ) and two forms, frmA and frmB. frmA has a command button (cmdA), an unbound list box (lstA) and a subform (sbfA). The AfterUpdate property of lstA refreshes sbfA. The OnClick property of cmdA opens frmB.

frmB is a modal pop up that adds a record into tblZ. frmB has a command button (cmdB) that closes frmB.

What I would like is to find a way to refresh frmA on clicking cmdB. I have tried the following in the OnClick property:

1. [Forms]![frmA].Refresh
2. [Forms]![frmA].Requery
3. [Forms]![frmA].[lstA].Refresh
4. [Forms]![frmA].[lstA].Requery
5. [Forms]![frmA]![lstA].Refresh
6. [Forms]![frmA]![lstA].Requery
7. Me.Dirty = False
DoCmd.Close acForm, "frmA"
DoCmd.OpneForm "frmA", acNormal, , , acFormEdit

As you can probably ascertain, none of these have worked. I have also tried adding Me.Refresh on the OnLoad, GotFocus, and OnActivate properties of frmA to no avail.

Any help would be greatly appreciated. Thank you in advance for your help. Have a good day.
 
You would need to first save the record and then requery the listbox A.

So, in the After Update event of the form B you should be able to use
Code:
Forms!frmA.lstA.Requery

And just closing form B, if it is bound to the table, should save the record.

So, just deal with closing the form in your command button (and you can use this code generically without having to change ANY of it):

Code:
DoCmd.Close acForm, Me.Name, acSaveNo
(the acSaveNo doesn't have to do with records. It has to do with design changes to the form).
 
Last edited:
And as usual, you have saved the day! Thank you for all of the help you give us on this forum!!
 

Users who are viewing this thread

Back
Top Bottom