Refresh parent form when subform deletes records

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a subform that can add/edit/delete records on the parent form. There
is a button on the subform that handles the delete process. At the end I want
the code to select the main form and refresh it to recognize the changes in
the records or the remove the deleted rows. I tried the following code, but
it doesn't work and replies "The expression you entered referrs to an object
that is closed or doesn't exist."


' Close subform after deleting record
DoCmd.Close
' Select primary form
DoCmd.SelectObject acForm, "frmPledge_Main", True
' refresh primary form
me.Refresh

Thanks for you help
 
Hello Andy.

Andy Roberts said:
I have a subform that can add/edit/delete records on the parent form.
There is a button on the subform that handles the delete process.
At the end I want the code to select the main form and refresh it to
recognize the changes in the records or the remove the deleted rows.
I tried the following code, but it doesn't work and replies "The
expression you entered referrs to an object that is closed or doesn't
exist."

' Close subform after deleting record
DoCmd.Close
' Select primary form
DoCmd.SelectObject acForm, "frmPledge_Main", True
' refresh primary form
me.Refresh

When this code (in the subform) executes DoCmd.Close, the current
object is closed, which is the main form i guess.
The form "frmPledge_Main" is selected in the database window.
I guess you want the following:
Me.Parent.Requery
 
Back
Top