Dependency

  • Thread starter Thread starter PeterM
  • Start date Start date
P

PeterM

I have two forms... A & B.

In form A is a listbox of all records in a table.
I have programmed form A so that when you click on an
entry in form A, form B is called which lets you edit
that record...simple enough.

The problem I'm having is that when you make your changes
in form B, save the record and close form B, I need form
A to do a requery to refresh the listbox. How can I call
a procedure from form B in form A to trigger the requery?
 
Peter,

You can make the call directly:
Forms!FormA.cboMyCombo.Requery

....or you can use OO techniques, by calling FormB as an object and using its
events to trigger an event procedure in FormA. Have a look at
http://www.pacificdb.com.au/MVP/Code/MyDialog.htm to see what I mean. Doing
things this way, you can make FormB resusable by keeping form-specific code
in the form to which it applies.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
In the code to open Form B, open the Form B in Dialog mode
(which will pause the execution of the code in Form A).
After the OpenForm statement, use the statements:
 
In the code to open Form B, open it in Dialog mode (which
will pause the execution of the code in Form A). After
the OpenForm statement, use statements somethinglike:

DoEvents
Me.lstListBox.Requery

HTH
Van T. Dinh
MVP (Access)
 
How can I call
a procedure from form B in form A to trigger the requery?

Forms!FormA!listbox.Requery

You don't need to execute any procedure in FormA - just requery it. If
the form's open it will work (if it's not, then you don't need to and
you can trap and ignore the error).
 
Back
Top