How to use .GoToRecord in Form_Load

Gates Is Antichrist

Well-known Member
Joined
Aug 15, 2002
Messages
1,961
The OpenTable below is insufficient to perform the GoToRecord. What is the minimal tweak or change I need?
Code:
Private Sub Form_Load()
    DoCmd.OpenTable Me.RecordSource
    DoCmd.GoToRecord acDataForm, Me.RecordSource, acGoTo, CLng(Me.OpenArgs)
End Sub
This is for a form recordsourced to a table. Without the form load, it works great, starting out on record 1; all I want to do is start it out on (e.g.!) record 77, as directed by its caller, DoCmd.OpenForm( ...77)
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
I'm probably missing something here, but when I want to open a form to a specific record, say record 7, I use:

DoCmd.GoToRecord acDataForm, "the form's name", acGoTo, 7

I works for me.
 
Upvote 0
Okay, that's it - the arg must be the form name, not recordsource. Me.Name works. Or
DoCmd.GoToRecord , , acGoTo, CLng(Me.OpenArgs)
Thanks very much!
 
Upvote 0

Forum statistics

Threads
1,221,877
Messages
6,162,579
Members
451,776
Latest member
bosvinn

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top