Set accNewRecord from on close event?

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

Guest

I know this must be easy but, I’m stumped.
I want to do the following things when a pop up form (thePopUp) is closed…
Requery a different sub form (theSubForm) that will be open when thePopUp is
open(got that figured out)
Set the focus of that same sub form to a new record row

So my On Close event of the pop up looks like this:
Private Sub ThePopUp_Close ()
‘This works…
Forms!theMainform!theSubForm.Requery
‘Here is where I’m having the problem…
‘This blows up…
DoCmd.GoToRecord acDataForm,
Forms!theMainform!theSubFormControl.SourceObject, acNewRec
End Sub

Any assistance is appreciated.

Thanks
Bernie
 
Your code are trying to perform a "GoToRecord" action on your popup form.
The DoCmd.GoToRecord command must run from your form "theMainForm".

You could create a Public Sub on theMainForm, that execute the
DoCmd.GoToRecord command.

In the popup form Close event you put a call to that sub, and the code are
executed on theMainForm.
 
Back
Top