Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Search as you type filter on combo box
Lauren Satterly 

12 years ago
I have the following code to search as you type into a combo box, but it keeps bugging when I complete a field. E.g. when I search for the TID (ID field) 300184 I can type 30018 but as soon as I hit 4 it bugs. I seem to be coming across this problem because I have added more than one combo box to search in different fields e.g. Contact Email, Company Name etc. because when I have just 1 it seemed to work fine. The code is below is for Combo Box 75 filtering the TID field and Combo Box 77 filtering the Gateway ID field. I only use 1 combo box at a time when searching:

Private Sub Combo75_Change()

' If the combo box is cleared, clear the form filter.
  If Nz(Me.Combo75.Text) = "" Then
    Me.Form.Filter = ""
    Me.FilterOn = False
  
  ' If a combo box item is selected, filter for an exact match.
  ' Use the ListIndex property to check if the value is an item in the list.
  ElseIf Me.Combo75.ListIndex <> -1 Then
    Me.Form.Filter = "[TID] = '" & _
                     Replace(Me.Combo75.Text, "'", "''") & "'"
    Me.FilterOn = True
  
  ' If a partial value is typed, filter for a partial company name match.
  Else
    Me.Form.Filter = "[TID] Like '*" & _
                     Replace(Me.Combo75.Text, "'", "''") & "*'"
    Me.FilterOn = True

  End If

  ' Move the cursor to the end of the combo box.
  Me.Combo75.SetFocus
  Me.Combo75.SelStart = Len(Me.Combo75.Text)

End Sub

Private Sub Combo77_Change()

' If the combo box is cleared, clear the form filter.
  If Nz(Me.Combo77.Text) = "" Then
    Me.Form.Filter = ""
    Me.FilterOn = False
  
  ' If a combo box item is selected, filter for an exact match.
  ' Use the ListIndex property to check if the value is an item in the list.
  ElseIf Me.Combo77.ListIndex <> -1 Then
    Me.Form.Filter = "[Gateway ID] = '" & _
                     Replace(Me.Combo77.Text, "'", "''") & "'"
    Me.FilterOn = True
  
  ' If a partial value is typed, filter for a partial company name match.
  Else
    Me.Form.Filter = "[Gateway ID] Like '*" & _
                     Replace(Me.Combo77.Text, "'", "''") & "*'"
    Me.FilterOn = True

  End If

  ' Move the cursor to the end of the combo box.
  Me.Combo77.SetFocus
  Me.Combo77.SelStart = Len(Me.Combo77.Text)
  
End Sub

Let me know if you have any ideas?

Thanks L

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/15/2026 6:39:59 AM. PLT: 1s