Solved

MS Access combo box - limited lookup limit

Posted on 2004-08-11
5
282 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
  • 3
  • 2
5 Comments
 
LVL 5

Accepted Solution

by:
jmacmicking earned 100 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now