Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I make command button that jumps forward 10 records

Status
Not open for further replies.

Jakobud

Technical User
Mar 9, 2001
51
US
I can make a command button (on a data access page) that jumps forward/backward 1 record at a time. That's easily done with the wizard. But how do make one that jumps forward more than one record at a time? If I have a database of 150+ records I don't want to sit there clicking the next button a million times just to get to the record I wanna edit...can anyone help me out here? And please be very specific because I am a beginner to Access. Thanks!

Jake
 
Jake,

Look at the code that the wizard made for you for going to the next record on that command button...

See the line that says?

DoCmd.GoToRecord , , acNext

Now change it to:

DoCmd.GoToRecord , , acNext, 10

Now click the button
 
Hmmm...I don't see the above code that you mentioned. There's something similar and I tried changing it a little similarly to yours, but no dice. Here is the code from the HTML document. I don't know javascript, so can you explain what I need to change here? Thanks!

<BUTTON id=Command0
style=&quot;BACKGROUND-IMAGE: url(./Navigation_files/image001.bmp); BACKGROUND-POSITION: center center; BACKGROUND-REPEAT: no-repeat; HEIGHT: 0.396in; LEFT: 4.542in; POSITION: absolute; TOP: 0.458in; WIDTH: 0.396in&quot;
tabIndex=10 title=Command0></BUTTON>
<SCRIPT event=onclick for=Command0 language=javascript>
try { MSODSC.CurrentSection.DataPage.MoveNext (); }
catch (e)
{ alert (e.description);}
</SCRIPT>
 
Jake i owe you an apology. i didn't read the &quot;data access page&quot; part of your post... that changes things
 
again, sorry i DON'T know java script

but if you can, have a look-see at the

MSODSC.CurrentSection.DataPage.MoveNext

routine that seems to be where the action is occuring.

advice, copy the routine & only change the copy...

Also, if no one else picks up the thread here try the same post in the &quot;Java Script&quot; forum
 
MSODSC is the DataSourceControl Object from the Microsoft Office Web Components object set. The .CurrentSection is to identify where your data is and returns a Section object. The .DataPage property is used to obtain the data from the Section and returns a DataPage object. The MoveNext method of the DataPage object is self explanatory. You can find more information at
A simple loop in the script block is the easist way to acomplish your task. The problem is that the MoveNext method generates an error when you attempt to move past the last record. The loop then generates multiples of this error type. Hopefully the break statement in the catch block will take you out of the loop and show you only the one error message you would receive normally.

<SCRIPT event=onclick for=Command0 language=javascript>
for(int i=0; i<10; i++) {
try { MSODSC.CurrentSection.DataPage.MoveNext (); }
catch (e)
{ break; alert (e.description);}
}
</SCRIPT>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top