472,964 Members | 2,452 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,964 software developers and data experts.

How to limit records displayed in ListBox?

Is there any way to limit the number of records loaded into a ListBox?

I looked at qdf.MaxRecords (to apply to the query that is the RowSource of
the ListBox) but that only applies to ODBC data sources. I also looked at
Tools > Options > Edit/Find and tried setting the "Don't display lists where
more than this number of records read:" property, but that doesn't help.

The List Box in question is supposed to allow scrolling/browsing of all
records in the database, but that gets to be a problem with tens of
thousands of records.

There are a number of options the user has to sort/filter/narrow the list to
find whatever is being searched for, so I'd like to limit the list to
something around 10,000 which would encourage the user to use the those
other features. Can this be done? Do I have to use something like SELECT
TOP 10000 [records] FROM tblData?
Nov 13 '05 #1
3 6545
The option on the Edit/Find tab is for the combo boxes when you go to
"filter by form".

One option, as you mentioned, would be to use a TOP query. Another option
would be to assign the row source to the list box via code. You could do a
count of the records returned in the code prior to assigning the query to
the row source. If the count is too great, popup a message to the user
telling them that too many records have been returned and to refine their
search. If the count is within reason, assign the query to the row source.

I think I remember reading that there is an option you can set in the
listbox or combo box when using an adp file to connect to SQL Server or
MSDE.

--
Wayne Morgan
MS Access MVP
"deko" <de**@nospam.com> wrote in message
news:HP********************@comcast.com...
Is there any way to limit the number of records loaded into a ListBox?

I looked at qdf.MaxRecords (to apply to the query that is the RowSource of
the ListBox) but that only applies to ODBC data sources. I also looked at
Tools > Options > Edit/Find and tried setting the "Don't display lists
where more than this number of records read:" property, but that doesn't
help.

The List Box in question is supposed to allow scrolling/browsing of all
records in the database, but that gets to be a problem with tens of
thousands of records.

There are a number of options the user has to sort/filter/narrow the list
to find whatever is being searched for, so I'd like to limit the list to
something around 10,000 which would encourage the user to use the those
other features. Can this be done? Do I have to use something like SELECT
TOP 10000 [records] FROM tblData?

Nov 13 '05 #2
> One option, as you mentioned, would be to use a TOP query. Another option
would be to assign the row source to the list box via code. You could do a
count of the records returned in the code prior to assigning the query to
the row source. If the count is too great, popup a message to the user
telling them that too many records have been returned and to refine their
search. If the count is within reason, assign the query to the row source.

I think I remember reading that there is an option you can set in the
listbox or combo box when using an adp file to connect to SQL Server or
MSDE.


TOP it is. In the Preferences Form of the app I let the user set the limit.
Of course I now have to dynamically build the SQL string and assign it the
query used for the RowSource. What I don't like about TOP is that it
returns records with lower autonumbered PKs first. So instead of returning
the most recent 10000 records entered, it returns the oldest 10000. I could
use ORDER BY to reverse this, but that slows down the query to the point
where it negates any speed increase gained by the lower record count.
Nov 13 '05 #3
On Mon, 22 Aug 2005 20:13:41 -0700, "deko" <de**@nospam.com> wrote:

In my mind if you do Top, you must also do OrderBy.
Not doing so, would typically return the records in PK order, but if I
understand SQL correctly, that is NOT a guarantee. I would gladly
sacrifice some performance for predictability.

OrderBy is not slow if issued on an indexed column.

-Tom.

One option, as you mentioned, would be to use a TOP query. Another option
would be to assign the row source to the list box via code. You could do a
count of the records returned in the code prior to assigning the query to
the row source. If the count is too great, popup a message to the user
telling them that too many records have been returned and to refine their
search. If the count is within reason, assign the query to the row source.

I think I remember reading that there is an option you can set in the
listbox or combo box when using an adp file to connect to SQL Server or
MSDE.


TOP it is. In the Preferences Form of the app I let the user set the limit.
Of course I now have to dynamically build the SQL string and assign it the
query used for the RowSource. What I don't like about TOP is that it
returns records with lower autonumbered PKs first. So instead of returning
the most recent 10000 records entered, it returns the oldest 10000. I could
use ORDER BY to reverse this, but that slows down the query to the point
where it negates any speed increase gained by the lower record count.


Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: middletree | last post by:
Yesterday, I posted a question which ended up giving me a lot of info, but the core question never got answered/solved. The short version is that when a page displays a number of records based on...
6
by: JohnH | last post by:
I have an ASP app (developed with Interdev 6) which uses a DTC listbox (server-side) bound to a recordset to allow the user to make a selection. This works fine until the number of records in the...
2
by: Danny | last post by:
How to allow users to select a set of records and then let them change a field for all these records at once? I would like to do this in code on a form. I will have a form with tabular view of...
3
by: DD | last post by:
I have a mainform with a subform. > The main form has a dropdown box "chooseMonth", in the afterupdate event > i requery the subform so all records with the same date are viewed. > Now i only want...
3
by: rodchar | last post by:
hey all, is there a way to limit the number of records in a dropdown and have scroll bars to see the rest of the records? thanks, rodchar
3
by: superjacent | last post by:
Hope someone can help. I have a listbox displaying time periods in blocks of 15 mins for a 24 hour period, all up 96 rows. The listbox can only visibly show 20 rows a time. The default...
2
by: claudia.carlotti | last post by:
Anyone knows how to avoid the limit to 36000 records that access has with a combo box? Any help will be appreciated. Many Thanks... Claudia
6
by: gerbski | last post by:
Hi all, I am relatively new to ADO, but up to now I got things working the way I wanted. But now I've run into somethng really annoying. I am working in MS Access. I am using an Access...
10
by: suzanne099 | last post by:
Hello, I am trying to use a list box based on a large query of records within an access form. The query contains 95,738 records, but the list box only lists 65,536. Is there a default limit...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.