Refresh parent form when subform deletes records

A

Andy Roberts

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
 
W

Wolfgang Kais

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top