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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limiting the number of records in a subform

Status
Not open for further replies.

sallieann

Programmer
Sep 2, 2003
28
GB
I have built an Access form which has a subform (in Continuous Forms view) to display a list of records. I don't want there to be a horizontal scrollbar on the subform and would like to limit the number of records to 15 per page. The user can then click on a "Next" button and see records 15-30 and so on. My code is as follows;

Private Sub next_15_Click()
On Error GoTo Err_next_15_Click

DoCmd.GotoRecord , , acNext, 15

Exit_next_15_Click:
Exit Sub

Err_next_15_Click:

Resume Exit_next_15_Click

End Sub

This is only moving my records on one more (showing 2-16), and if I make the window smaller (to show 14 records), it moves it on to 17 onwards!? Can anybody explain why and point me in the right direction to solve this problem? Any help is greatly appreciated.

Many thanks in advance.
 
The problem is that the GotoRecord method, as you have it, goes to the 15th record from its current position. If you are testing the form and you are currently sitting on record 1 and you click the button, you will then be moved to record 16. That is 15 records from the current record, which is 1. If you are sitting on record 3, it would move from 3 to 3+15.

Does that make sense? What you would need to do is put some kind of test there and if it is not on the last record displayed, then move it to that last record before calling your code to move it 15 records.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top