Move to next record on Subform.

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
mattcolenutt [ Di, 22 April 2008 12:49 ] [ ID #1947631 ]

Re: Move to next record on Subform.

"Lynx101" <mattcolenutt [at] gmail.com> wrote in message
news:cd0a9211-1b7d-4326-9920-b29caa034562 [at] 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.
Stuart McCall [ Di, 22 April 2008 13:29 ] [ ID #1947632 ]

Re: Move to next record on Subform.

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.
mattcolenutt [ Di, 22 April 2008 14:33 ] [ ID #1947637 ]

Re: Move to next record on Subform.

"Lynx101" <mattcolenutt [at] gmail.com> wrote in message
news:cd0a9211-1b7d-4326-9920-b29caa034562 [at] 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
Fred Zuckerman [ Di, 22 April 2008 15:27 ] [ ID #1947640 ]
Datenbanken » comp.databases.ms-access » Move to next record on Subform.

Vorheriges Thema: Moving a VBA function to SQL server
Nächstes Thema: Listbox displaying 0 and -1 instead of Yes/No