X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
   Reply to this topicStart new topic
> Creating Vba Code To Move To Next Record In Subform, Access 2010    
post Apr 8 2019, 10:56 AM

Posts: 17
Joined: 6-March 19

Hi All,

I have a subform (tblBufferListSubform) embedded into my main form (LandingPage). After I enter a record in the subform on LandingPage, I want to be able to click a button on LandingPage that will take me to the next blank space to enter a subsequent record on the subform. Right now, I have to click the down arrow to do this.

I also have the button set to run two queries. I need to hit the down arrow before running the queries or the record I entered into the subform will not take.

Attached is my code on the subform and on Landing Page. Right now, when I click the button, I get a Compile Error: Method or data member not found and it highlights Public Sub MovetoNext() on my subform.

Any help would be appreciated!

Attached File(s)
Attached File  SubForm_Code.PNG ( 5.55K )Number of downloads: 0
Attached File  LandingPage_Code.PNG ( 11.33K )Number of downloads: 0
Go to the top of the page
post Apr 8 2019, 11:17 AM

UA Moderator
Posts: 76,911
Joined: 19-June 07
From: SunnySandyEggo

Hi. You're code looks okay, probably just need a small tweak. Can you post a sample/demo to try out?

Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
post Apr 26 2019, 04:48 AM

UtterAccess VIP
Posts: 4,751
Joined: 5-June 07
From: UK

This should work as well

runcommand acCmdRecordsGoToNext

for a new record

runcommand acCmdRecordsGoToNew

Dave (Male)

(Gemma was my dog)
Go to the top of the page
post Oct 3 2019, 05:48 PM

Posts: 72
Joined: 19-May 16

I just went thru something similar and the solution wasn't what I expected.

If you have a subform you have to work with the reference SubformName.Form.Method, aka variable = tblBufferListSubform.Form.ActiveControl
The SubformName.Form was the key bit to reference the subform directly from the main form buttons, otherwise I couldn't get it to work.
Go to the top of the page
post Oct 4 2019, 02:22 AM

Posts: 1,510
Joined: 2-April 09
From: somewhere out there...

you need to Setfocus on the Subform 2x times to
get it working:
Public Sub MovetoNext()
    ' set focus 2x
On Error Goto MoveToNextErr
    DoCmd.GotoRecord , , acNext

    Exit Sub
    Msgbox "Can't go beyond further!"
End Sub

Never stop learning, because life never stops teaching.
Go to the top of the page

Custom Search

RSSSearch   Top   Lo-Fi    16th December 2019 - 08:56 AM