• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 341
  • Last Modified:

MS Access combo box - limited lookup limit

Hi,
I have a combo that searches a specific field in a table of several thousand records.  The user types in the first couple of digits and the combo begins to auto-select.  My problem occurs when the user requests a record that is "way down" the list, whereby the auto-select seems to reach a limit and stop.  I have, therefore, had to set the combo to "Limit To List = No", where ideally I want to "Limit To List  = Yes".  This is because other fields are propogated automatically upon record selection.  Is there a hidden natural limit within Access that can be turned off, or is there a property somewhere, where the number of records to be read can be defined?

Thanks in advance.

Keith Blakesley
0
keithedwardb
Asked:
keithedwardb
  • 3
  • 2
1 Solution
 
jmacmickingCommented:
There's a limit in the combo box and list box controls--we've run into it when listing all the users in the domain.  I know it's in the thousands range but I'm not sure what is exactly.  If I find the MS link I'll post it.

Maybe it's possible to get around the problem--for instance by leaving the data source of the combo box blank until the person has filled in several letters.  At that point change the data source of the combo box to select only the records that match the letters the user has already typed (you'll probably have to run the requery action on the combo box to refresh the list).  This should cut down on the total number of records you need to display.
0
 
keithedwardbAuthor Commented:
Thanks for the reply.  I'll let you know if this works, although I might be day or so before I can get back to it.
Regards,
Keith Blakesley
0
 
keithedwardbAuthor Commented:
I tried to get the requery to run, but numerous errors kept occurring.  But using your idea I got around the problem by running a query at the head of the form that built a table of the 27,000 prefixes I was looking for.  When this was grouped, I was able to use this list as a Prefix selection combo that helped then drive the final search.  A bit long winded, but it worked.  Thanks again for the thought trigger.

Regards,
Keith Blakesley
0
 
jmacmickingCommented:
Here's the code I used to keep everything in one combo box.  The combo box should initially be set for RowType="Value List" and RowSource = "".  Set the code on the combo box's change event to the following:

______________________________________________

Dim IsUpdating As Boolean

Private Sub Combo0_Change()
    Dim strTemp As String
   
    If Not IsUpdating Then
        IsUpdating = True
       
        If Len(Combo0.Text) > 2 And Not Len(Combo0.RowSource) > 0 Then
            Combo0.RowSourceType = "Table/Query"
            Combo0.RowSource = "SELECT [YourRowName] FROM [YourTableName] WHERE LEFT([YourRowName],3)='" & Left(Combo0.Text, 3) & "' ORDER BY [YourRowName]"
            strTemp = Combo0.Text
            Combo0.Text = ""
            Combo0.Requery
            Combo0.Text = strTemp
            Combo0.SelStart = Len(Combo0.Text)
            Combo0.SelLength = 0
            Combo0.Dropdown
        End If
       
        If Len(Combo0.Text) < 3 And Len(Combo0.RowSource) > 0 Then
            strTemp = Combo0.Text
            Combo0.Text = ""
            Combo0.RowSourceType = "Value List"
            Combo0.RowSource = ""
            Combo0.Text = strTemp
            Combo0.SelStart = Len(Combo0.Text)
            Combo0.SelLength = 0
        End If
       
        IsUpdating = False
    End If
End Sub

______________________________________________


IsUpdating needs to be a global variable on the form; so long as it is declared outside the scope of any Subs or Functions it should be fine.  It's used to prevent the code from re-running when the value of the combo box is changed halfway through the Sub.

Once the text the person types in reaches 3 characters the code changes the combo to use a query as it's row source.  It then stores the current value of the text and clears the combo box.  This is necessary for the requery to run properly.  After it forces the requery it puts the text back, moves the selection to the end of the text (it defaults to the front if you don't) and opens the drop down.

If the text is less then 3 characters it sets the combo box back to "Value List" and the row source back to blank.

You need to use >3 to check for text length to allow for people pasting in values.  That's also why the RowSource query is set to the left 3 letters of the text instead of assuming it's three letters.
0
 
keithedwardbAuthor Commented:
Thankyou.  VB isn't my forte although I do dabble.  I will have a go with this.  Thanks for response.

Best Regards,
Keith Blakesley
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now