In the code in the main form, open the popup form in dialog mode. The
Docmd.OpenForm method has a parameter called WindowMode that allows you to
open it this way. The advantage is that this code waits until the popup form
is closed to continue executing. This allows you to do this:
DoCmd.OpenForm "frmAddRecord", WindowMode:=acDialog
DoCmd.RunCommand acCmdRecordsGoToLast
The 2nd line won't execute until frmAddRecord has closed.
HTH,
Barry
"Zilla" wrote:
> Hi ,
>
> I have a pop up form which allows users to add a new record. When the popup
> is closed, I have a Requery run at OnClose so that the Main Form
> ("frmcypNew") is updated with the new record. This works fine.
>
> What I want to do is: have it so that the main form (which shares a
> recordsource with the popup) will goto the Last Record (ie the new one) when
> the popup closes.
>
> I have tried:
> DoCmd.GoToRecord acDataForm, "frmcypNew", acLast
> in the OnClose, Deactivate and Unload events on the popup form - nothing
> happens.
>
> I have tried:
> DoCmd.GoToRecord acLast
> in the GotFocus event of the mainform - to no avail - and the same in the
> Current event of the main form - This does work, but causes problems when
> trying to view any records other that the newly entered (ie makes it
> impossible).
>
> What code do I need and where?
>
> Thanks in advance
> Jim
>
>
|