473,387 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

filter a combo box in a continuous form

12
hi
i have a combo box in continuous form is there a way that i can filter the combo as i write in it?
Jul 14 '08 #1
3 4633
puppydogbuddy
1,923 Expert 1GB
Yes, highlight the combobox in design view, invoke the property sheet, then set the auto expand property to yes.
Jul 14 '08 #2
dmcp
12
this is not what i meant. what i need is to show the records that contain the characters that i wrote in the combo box
Jul 15 '08 #3
Stewart Ross
2,545 Expert Mod 2GB
Hi dmcp. It would help us to help you if you would provide enough detail when asking a question so that our expert contributors, who give their time freely and voluntarily, are not misled. In your one-sentence question you did ask about filtering the combo as you wrote in it, not filtering your form. The answer given by Puppydogbuddy was accurate for the question you asked; unfortunately what you asked was not what you really meant.

After you have finished typing whatever characters you want to match into your combo you can apply a filter to the recordsource of your form using VBA code in the After Update event of your combo. You have not provided names of controls or underlying fields so the following skeleton code uses dummy names which you will need to replace.

In design mode select the combo and bring up its properties. Right click on the After Update event and select Build, Code. The VB Editor will be started with an empty After Update subroutine. Copy and paste the following, replacing the dummy names as appropriate:
Expand|Select|Wrap|Line Numbers
  1. Dim ComboContents as Variant
  2. ComboContents = Me![name of your combo control]
  3. If IsNull(ComboContents) then
  4.     Me.Filteron = False ' cancel filter if combo cleared
  5. else
  6.     Me.Filter = "[name of the field you want to filter] Like *" & ComboContents & "*"
  7.     Me.Filteron = True
  8. end if
This just applies a filter to the form on whatever field it is you want to filter. The wild card "*" characters are used to ensure matching on any text before and after the characters you want to find.

The filter is cancelled by clearing the combo box (tested for null above) but you may wish to put a command button on the form marked 'show all' to do this for your users instead.

-Stewart
Jul 15 '08 #4

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

Similar topics

3
by: Richard | last post by:
Hi, I have a form based on a table. When I filter the form I want to run a report based on the same table with the same filter as the form. No problem until I want to filter a combo box where...
3
by: B | last post by:
I know there are several ways to speed up combo boxes and form loading. Most of the solutions leave rowsource of the combo box blank and set the rowsource to a saved query or an SQL with a where...
6
by: Ralph2 | last post by:
Some time ago with a lot of help from this group I made a reasonably successful database to keep track of our shop drawings. However the searching mechanism is too complicated for the occasional...
3
by: Stewart | last post by:
Hi all! My (relatively small) database holds data on staff members and the projects (services) that they are assigned to. In my form frmStaff, I have a list of staff members - it is a...
9
by: Edwinah63 | last post by:
Hi everyone, Please let there be someone out there who can help. I have two BOUND combo boxes on a continuous form, the second being dependent on the first. I have no problem getting the...
0
by: Jeremy Wallace | last post by:
Folks, Here's a write-up I did for our developer wiki. I don't know if the whole rest of the world has already figured out how to do this, but I hadn't ever seen it implemented, and had spent a...
6
by: bammo | last post by:
MS Access 2003, Windows XP SP2, VBA I have a continuous form that allows edits and filters, but not deletions or additions. I filter the form based on combining selections the user makes in...
5
by: Thelma Lubkin | last post by:
I quote: "With an unbound combo in the form's header, you could provide a ------ simple interface to filter products from one category." I've underlined my uncertainty: is the combo placed in...
2
by: franc sutherland | last post by:
Hello, I am using Access 2003. I have a query which shows a list of club meetings sorted by date. This query is displayed in continuous forms, in a subform. I would like to select a month on...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...

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.