tags:

views:

804

answers:

9

I have a table of 155K records. I can scroll only 65K records in combo box of a form having recordsource with query or sql, selecting three fields from that table. Why it does not list all 155K records even the query, which I am using as recordsource, shows all records outside of the form.

+15  A: 

perhaps the item index is a 16-bit integer

a better question would be, do you really expect the user to scroll through 155 thousand items in a combobox?

Steven A. Lowe
This is correct. Excel / Access have a limit: 16-bit integer. I am guessing he wants to do something with that data such as search/replace from that UI on the entire dataset- which won't fully load.
Klathzazt
+4  A: 

Another person in agreement that this would be an insane way to give the user access to this data. No one will ever want to parse through 100k + records at once. I would provide a way to filter the records beforehand so that they are only presented with the ones that are of interest at the time.

Ed Swangren
A: 

65536 is indeed the limit for the number of combobox items.

I would suggest using a text box with a search button to find someone from the list rather than using a combo box in this case.

As alternative you could load the items dynamically dependent from the text inserted.

You could also try to "prefilter" your combobox via a previously entered value on your form to get the number of records returned below the maximum allowed. For example, if your table had 100,000 worth of names and addresses, You would have the user enter (before using the combobox) a zipcode, or state that would be used to filter the number of records your combobox query RecordSource returns.


@ Steven A. Lowe and amdfan: do you know what a combobox is and why it is called combo-box? It's a textbox combined with a listbox. You type a text and the listbox show the first entries matching your text.

So, I guess that's a legitimate question.

splattne
yes, i do - and the drop-down list part should never exceed a few tens of items, for usability.
Steven A. Lowe
not to mention load-time!
Steven A. Lowe
It all depends on how the loading in the combobox is implemented.
splattne
ya gotta be kidding me - (a) 65535 rows in a list is too many even if it loads instantly, (b) the combobox list won't hold all of the items; now if you mean 'load incrementally', that's different...
Steven A. Lowe
+2  A: 

So what you're really looking for is more an "Auto-complete" functionality, like what's seen in internet browsers? When you say combo-box, everybody pictures a drop-down where the user selects an item - you may want to clarify your question.

rwmnau
The Access combo box already has an Autocomplete feature. What is needed is filtering of the results returned.
David-W-Fenton
+1  A: 

As a general rule, when you run into a hardcoded limit on a general and widely used component like a combobox, it's time to reconsider your approach. The combobox isn't designed for, and isn't sufficient for, your use case. Take a couple steps back from your project and re-evaluate your UI. Perhaps a ListView or a filtered data grid would be more appropriate.

Greg D
The Access listbox has the same limitations as the Access combo box. There is no ListView or data grid in Access (why would you bother to suggest something that doesn't exist?), but subforms are fine for many records. The problem in this case is a question of filtering, not choice of control to use.
David-W-Fenton
A: 

It is not too difficult to create a textbox and listbox combination where the listbox is requeried in the change event of the textbox, progressively narrowing the items selected. This would mean that your users can still see a list of names, rather than guessing, but a much shorter and more relevant list.

Here is sample SQL for the RowSource of such a listbox:

SELECT tp.PersonKey, 
   tp.Surname & ", " & tp.Forename AS PersonName
FROM tblPersons tp
WHERE tp.Surname 
LIKE Forms!MyForm!txtSurname.Text
ORDER BY  tp.Surname, tp.Forename

Note the use of the Text property of the textbox, this ensures that the current contents of the textbox are used, but it also means that the textbox cannot be requeried except when txtSurname has focus, which is fine, because the requery should only be done in the change event of txtSurname.

Remou
Much simpler is to assign the combo box's rowsource in the combo box's OnChange event -- fewer controls involved and self-documenting.
David-W-Fenton
There can be quite a few difficulties with that, as can be seen from Allen Browne's example http://allenbrowne.com/ser-32.html
Remou
A: 

It difficult to use in the real world, combobox store 155k records i think if change it to [...] browse button or other control I easy to use more than this way

Fuangwith S.
+2  A: 

Try something like incrementally filled combobox. e.g. the way tag search work in Stack Overflow, or the way Google Suggest works. 65k is good enough a limit for combobox. A normal user will find difficulty in selecting from even 65 things

Varun Mahajan
+1 for "65k is ... enough". Reminiscent of "640K is enough...".
Asaf R
Yeah, pun was intended ;)
Varun Mahajan
+1  A: 

The simplest approach is to assign the combo box's Rowsource only after you type some characters in it. You'd do that in the combo box's OnChange event:

  Dim strRowSource As String

  strRowSource = "SELECT MyID, MyField FROM MyTable"
  If Len(Me!cmbMyCombo.Text)=3 Then
     strRowSource = strRowSource & " WHERE MyField Like '" 
     strRowSource = strRowSource & Me!cmbMyCombo.Text
     strRowSource = strRowSource & "*'"
     Me!cmbMyCombo.RowSource = strRowSource
     Me!cmbMyCombo.DropDown
  End If

When you type into the combo box, nothing happens until you've typed 3 characters (or 2 or 4 or whatever is appropriate to filter your dropdown list down to a human-usable number of records), at which time the rowsource is assigned (and, if you like, you can dropdown the list at that point, to make it more user-friendly). From then on, it will work just like any normal combo box.

If you need to use the same combo box to display data in records that aren't entered, then you could make the combo box's default Rowsource be:

  PARAMETERS [Forms]![MyForm]![MyField] Text ( 255 );
  SELECT MyID, MyField FROM MyTable WHERE MyField = [Forms]![MyForm]![MyField];"

Then in your OnChange event, you'd do this:

  Dim strRowSource As String

  strRowSource = "PARAMETERS [Forms]![MyForm]![MyField] Long; "
  strRowSource = strRowSource & "SELECT MyID, MyField FROM MyTable "
  strRowSource = strRowSource & "WHERE MyField = [Forms]![MyForm]![MyID]"
  strRowSource = strRowSource & "UNION SELECT MyID, MyField FROM MyTable"
  If Len(Me!cmbMyCombo.Text)=3 Then
     strRowSource = strRowSource & " WHERE MyField Like '" 
     strRowSource = strRowSource & Me!cmbMyCombo.Text
     strRowSource = strRowSource & "*'"
     Me!cmbMyCombo.RowSource = strRowSource
     Me!cmbMyCombo.DropDown
  End If

Then in the OnCurrent event of the form, you'd do this:

  Dim strRowSource As String

  strRowSource = "PARAMETERS [Forms]![MyForm]![MyField] Text ( 255 ); "
  strRowSource = strRowSource & "SELECT MyID, MyField FROM MyTable "
  strRowSource = strRowSource & "WHERE MyField = [Forms]![MyForm]![MyField]"
  Me!cmbMyCombo.RowSource = strRowSource

What this accomplishes is to make sure that any value already assigned to the field the combo box is bound to will still display. If you have a blank RowSource, that won't work, so the reference to the form's current value for that field and UNION it with the filtered list.

--
David W. Fenton
David Fenton Associates

David-W-Fenton
an excellent suggestion. You might be interested in an unrelated question http://stackoverflow.com/questions/277128/what-is-the-policy-on-signatures-and-links-in-answers-for-so-questions
Steven A. Lowe