?
Solved

MS Access combo box - limited lookup limit

Posted on 2004-08-11
5
Medium Priority
?
328 Views
Last Modified: 2010-04-17
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
Comment
Question by:keithedwardb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 5

Accepted Solution

by:
jmacmicking earned 300 total points
ID: 11777827
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
 

Author Comment

by:keithedwardb
ID: 11783134
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
 

Author Comment

by:keithedwardb
ID: 11808046
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
 
LVL 5

Expert Comment

by:jmacmicking
ID: 11809297
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
 

Author Comment

by:keithedwardb
ID: 11809423
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Progress
Starting up a Project

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question