Set accNewRecord from on close event?

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
 
G

Guest

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.
 

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