Solved

MS Access combo box - limited lookup limit

Posted on 2004-08-11
5
303 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
topping3 challenge 14 81
How  do I get an older program to run in Windows 10? 20 111
Path of Workbook 3 79
Delphi: barcode reading on android platform 1 30
I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

831 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