Move to next record on Subform.

Move to next record on Subform.

am 22.04.2008 12:49:01 von mattcolenutt

I am trying to move a subform onto the next record with:

DoCmd.GoToRecord acForm, "MaintainAssets_edit", acNext

but when I do this I get "The object 'MaintainAssets_edit' is isn't
open". I know I could easily put the controls in the subform itself
but I want the record controls at the top of the page, outside of the
subform.

Thanks for looking.

Matt

Re: Move to next record on Subform.

am 22.04.2008 13:29:38 von Stuart McCall

"Lynx101" wrote in message
news:cd0a9211-1b7d-4326-9920-b29caa034562@m36g2000hse.google groups.com...
>I am trying to move a subform onto the next record with:
>
> DoCmd.GoToRecord acForm, "MaintainAssets_edit", acNext
>
> but when I do this I get "The object 'MaintainAssets_edit' is isn't
> open". I know I could easily put the controls in the subform itself
> but I want the record controls at the top of the page, outside of the
> subform.
>
> Thanks for looking.
>
> Matt

Open the form MaintainAssets_edit in design view. Switch to the VB
environment and create a public procedure in the form's module:

Public Sub MoveToNext()
DoCmd.GoToRecord acForm, Me.Name, acNext
End Sub

Save the form, then in your main form, substitute the DoCmd line with:

Me.SubformControlName.Form.MoveToNext

Replace 'SubformControlName' with the name of the control housing the form
MaintainAssets_edit.

The procedure is visible to the main form because it is declared Public. The
code executes in the context of the subform.

Re: Move to next record on Subform.

am 22.04.2008 14:33:14 von mattcolenutt

Really appreciate your response. I've put in the code but still get
"The object 'MaintainAssets_edit' is isn't open". The only other thing
I can say about the sub form that allowedits=false. Really wierd.

Re: Move to next record on Subform.

am 22.04.2008 15:27:50 von Fred Zuckerman

"Lynx101" wrote in message
news:cd0a9211-1b7d-4326-9920-b29caa034562@m36g2000hse.google groups.com...
>I am trying to move a subform onto the next record with:
>
> DoCmd.GoToRecord acForm, "MaintainAssets_edit", acNext
>
> but when I do this I get "The object 'MaintainAssets_edit' is isn't
> open". I know I could easily put the controls in the subform itself
> but I want the record controls at the top of the page, outside of the
> subform.
>
> Thanks for looking.
>
> Matt

Matt,
Set focus to the subform, then move next, then set focus back to main form.
Fred Zuckerman

' Caution: Air Code
Me.SubForm.SetFocus
DoCmd.GoToRecord ,, AcNext
Me.MainForm.SetFocus