Only show 10 records in a subform

naym

Registered User.
Local time
Today, 10:11
Joined
Aug 30, 2006
Messages
47
Hi all

I have a subform which loads the items from a table the form is non editable just for viewing the items, the problem is how can i
A. limit the subform to only show the first say 10 items in the subform
B, to have a command button on the form where the the subform is on (command button not in the form) and when the user clicks it it goes to the next set of records say from 11 to 21 and displays that in the form.

i tried doing record cound but somehow record count is not there when selecting, also would the code go in the subfrom on load or on the form load where the subform is based?

any help on this would be appreciated.

thanks.
 
Hi naym,

What I would do is physically change the size of the subform to only show 10 records.
Put a button on the main form with the following code in the "on click" event.
It should move the records forward by 10 each time you click the button.

Code:
DoCmd.GoToControl ("Subformname")
DoCmd.GoToRecord , "", acNext, 10

This code is untested so let me know if it fails.

Also if the records are only for viewing and not editing it might be worth while changing the recordset type to Snapshot instead of dynaset. It will load a little bit faster.

Garry
 
Hi Garry
Thanks for the reply yes that does work but it seems to miss a few out for some reason. just having a go at it now
 
The order of the data in the table may not be the order you think it is. You can impose order by basing your subform on a query and applying the sort in the query. That may well stop the 'missed' records.
 
Hi Niel,


On that note, just out of curiosity, If the table has never been sorted (A-Z etc) is it displayed in its indexed state?

Garry
 
Garry,

Regardless of Primary Keys and/or indexes, unless you explicitly sort records
in your form/query/report, they are in random order.

It may not "look" like it at times, but they are random unless otherwise
specified.

Wayne
 
Hi Wayne,

I've never really thought about this before, because "obviously" I sort or group them as and when I display them or print them etc, so its never been an issue to me.

Cheers

Garry
 
I agree with Wayne. Remember that when you look at your data in table view, that is not the raw data, it is a view. Normally the view will be in index or chronological order, but, as Wayne observes, the raw data will be all over the place.
 

Users who are viewing this thread

Back
Top Bottom