473,586 Members | 2,695 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Combo Box Filtering

134 New Member
I have create a combo box, which show all student names in the 1st column, If I want to find name call Jack, I would type the frist few character say JAC, automatically the combo box will point me to the nearest name that start with JAC,

How can I only show those students names that start with JAC..., in the combo box list, and hide the rest of the student names that not start with JAC.
Jan 7 '07 #1
13 3060
hariharanmca
1,977 Top Contributor
I have create a combo box, which show all student names in the 1st column, If I want to find name call Jack, I would type the frist few character say JAC, automatically the combo box will point me to the nearest name that start with JAC,

How can I only show those students names that start with JAC..., in the combo box list, and hide the rest of the student names that not start with JAC.

for this better you can use a listview and textbox because if you want to do that in comboBox you have to clear the combo list and there may clearing combo text also.

so, better you can use a listview and textbox
Jan 7 '07 #2
jamesnkk
134 New Member
for this better you can use a listview and textbox because if you want to do that in comboBox you have to clear the combo list and there may clearing combo text also.

so, better you can use a listview and textbox
I know how to build this in a List box, but may not suitable in my current form development, would you mind explain what you mean by clea the combo list and combo text.
Jan 7 '07 #3
ADezii
8,834 Recognized Expert Expert
I have create a combo box, which show all student names in the 1st column, If I want to find name call Jack, I would type the frist few character say JAC, automatically the combo box will point me to the nearest name that start with JAC,

How can I only show those students names that start with JAC..., in the combo box list, and hide the rest of the student names that not start with JAC.
'You can programmaticall y change the RowSource Property of the Combo Box. Assuming a Combo Box name of cboTest with Column Count = 1, Bound Column = 1, RowSourceType = Table/Query, and a [FirstName] Field in tblEmployees:
Expand|Select|Wrap|Line Numbers
  1. Dim MySQL As String
  2. MySQL = "SELECT tblEmployees.FirstName FROM tblEmployees WHERE " _
  3.         & "tblEmployees.FirstName Like 'JAC*' ORDER BY tblEmployees.FirstName;"
  4.  
  5. Me![cboTest].RowSource = MySQL
  6. Me![cboTest].Requery
Output: Produces only First Names that begin with JAC...
Jan 7 '07 #4
jamesnkk
134 New Member
'You can programmaticall y change the RowSource Property of the Combo Box. Assuming a Combo Box name of cboTest with Column Count = 1, Bound Column = 1, RowSourceType = Table/Query, and a [FirstName] Field in tblEmployees:
Expand|Select|Wrap|Line Numbers
  1. Dim MySQL As String
  2. MySQL = "SELECT tblEmployees.FirstName FROM tblEmployees WHERE " _
  3.         & "tblEmployees.FirstName Like 'JAC*' ORDER BY tblEmployees.FirstName;"
  4.  
  5. Me![cboTest].RowSource = MySQL
  6. Me![cboTest].Requery
Output: Produces only First Names that begin with JAC...
Thanks for the code, but in your sql statement, you defined Jac, what I mean is just an example user may type in jac or Pet or any characters, how would I put into the sql ?
Jan 7 '07 #5
NeoPa
32,566 Recognized Expert Moderator MVP
James,
What you're asking for is a redefinition of the ComboBox object itself. Alternatively, handle the keypresses. You will discover just how many different situations need to be handled for it to work properly.
I'm afraid the short answer is that this is not supported.
Jan 8 '07 #6
jamesnkk
134 New Member
James,
What you're asking for is a redefinition of the ComboBox object itself. Alternatively, handle the keypresses. You will discover just how many different situations need to be handled for it to work properly.
I'm afraid the short answer is that this is not supported.
Thanks, you understand my question, I got this idea which I saw an application was able to handle it. You are right, When I try different method, I realize th hardest part was the keypress. Adezil also provide a very good solution
Jan 8 '07 #7
Killer42
8,435 Recognized Expert Expert
Thanks, you understand my question, I got this idea which I saw an application was able to handle it. You are right, When I try different method, I realize th hardest part was the keypress. Adezil also provide a very good solution
Your simplest option might be to have a separate textbox where the user types the search string. Each time the value is changed in the textbox, requery the combobox with the modified WHERE clause.

Question for the experts - does the Access combobox have a Sorted property, as in VB6? I couldn't see one.
Jan 8 '07 #8
NeoPa
32,566 Recognized Expert Moderator MVP
I read your post Killer and thought 'He's ripped that from my post.'
Then I reread my post and remembered I'd taken that idea out :sheepish grin:
A problem with that idea is that getting access to the characters passed is not too easy until BeforeUpdate is triggered.
You can do it, but it's very fiddly.

A ComboBox doesn't have a sorted facility, but the RowSource can easily include a sort (Either an ORDER BY if it's SQL or sorting within a QueryDef - Tables are more complicated :().
Jan 8 '07 #9
Killer42
8,435 Recognized Expert Expert
I read your post Killer and thought 'He's ripped that from my post.'
Then I reread my post and remembered I'd taken that idea out :sheepish grin:
This is not the first time we've been guilty of thinking alike.
It's nice to meet another intelligent person now and then. :)

A problem with that idea is that getting access to the characters passed is not too easy until BeforeUpdate is triggered.
You can do it, but it's very fiddly.
I'm afraid you lost me there. Which "characters passed" are you referring to? If you mean the value of the textbox, I'd have thought the OnChange event would allow you to do it pretty easily. Not that I have much experience in this area (in VB, yes; Access, no).

A ComboBox doesn't have a sorted facility, but the RowSource can easily include a sort (Either an ORDER BY if it's SQL or sorting within a QueryDef - Tables are more complicated :().
Yeah, the SQL posted here included the ORDER BY, and I just wondered whether it was necessary. Guess I just find it hard to accept how much functionality MS threw away when "porting" VB to Access, etc.
Jan 8 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
5438
by: Sean | last post by:
Greetings all, I am attempting to make a form that will filter through several tables that (I believe) have refretial integrity. I am pulling data from several tables into the form and i would like to eventually be able to filter down through the tables untill i can reach one unique record. I am creating a datbase to keep track of...
0
1730
by: Scott Loupin | last post by:
I've got two databases with similar data in them (WestSide and EastSide). I've set up two identical reports that is filtered by date and the client name. I'm using one form to do the filtering. Currently, I've used queries to combine the two client lists, so when I open the combo box, I have many names I need to scroll through until I find...
1
1861
by: MLH | last post by:
I have a form (xxxxxxxxxxxxxx) with a combo-box control (yyyyyyyyyyyyyy). The rowsource property for that combo box is as follows: SELECT DISTINCTROW ., . FROM ; The SQL for qryVehicleList is ... SELECT & " " & & " " & & " & "]" AS Vehicle, tblVehicleJobs.VehicleJobID, tblVehicleJobs.OwnerID, tblVehicleJobs.AuthID,...
3
5332
by: Mike Jakes | last post by:
I hope that someone can offer a little advice on this one - I've searched the group but can't find an answer. I think that I'm doing something really stupid or missing something trivial, but see what you can make of this... I have a main form "Events" that contains a tab control. The tab control has 7 pages. The 7th page (named "Boats")...
4
1918
by: tlyczko | last post by:
I read about limiting combo boxes' list data, for example, limiting the list of values in the second combo based on values in the first combo, and I found the Dev Ashish site link. I have two combos based on lookups of very small tables, Audit Descriptions and Programs. Combo 1: Audit Descriptions has Comprehensive, Fire Safety, Medical,...
1
3861
by: hackerslacker | last post by:
I have an ordering form that use two combo boxes to filter down the records of a Products table. This worked fine with the after_Update of the first filtering the records and creating the rowsource of the second combo. The second combo's control source is the Product ID field (foriegn key) on the Orders table. Everything worked well until...
5
3686
by: jjyconsulting | last post by:
Newbie needing some help. I have a tblParticipants. The fields include gender, education_level, income, occupation etc., I'm trying to create a form where a user can run a query from the form and just choose the appropriate criterias from the combo boxes to get the results. I also want the query to run even if there is not a value in all...
8
8243
by: salad | last post by:
I was wondering how you handle active/inactive elements in a combo box. Let's say you have a combo box to select an employee. Joe Blow has been selected for many record however Joe has left the company and has been flagged inactive. If you have a filter on the rowsource like Where Active = True then Joe's name would not show up in the combo...
2
2605
by: Dev1 | last post by:
All- I'm new to this forum and i've been working with acces for about 2 days now. I have a form in which I have two combo boxes and depending on what is selected on the first dropdown the second one gets populated accordingly, which is great! There are two problems; First the when I select the value from the second drop down the value in...
3
1806
by: flymo | last post by:
Hello All, I've bee trying out access 2007 and have a weird issue and would like to see if I'm issing something really basic. I have a form based on a query, I create a combo to look for records on my form based on Org_ID. Wgen I create all is fine - I type e, combo goes to e and starts filtering etc just like normal......I save the form,...
0
7908
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7836
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8212
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6606
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5389
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2343
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1175
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.