Re: use 1 combobox instead of 4
- From: "Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx>
- Date: Tue, 13 Mar 2007 23:53:14 +0900
Fortunately, the FindAsUType code is dead simple to employ, even if it isn't so easy to understand.
Most of the complexity in the code involves figuring out which fields the user can see on the form, and the name the user knows them by, and the data type of each field, and whether the value shown in the combos is the actual value stored in the field, and if not whether your version of Access is able to filter that field, and the order of the fields on the form including any that may be on subsequent tab pages, so it can load the combo with the fields that can be filtered, along with a display name, field name, and data type, so you can use it on any form without knowing anything about the form and its data ahead of time.
Once the combo is loaded with the data about the fields, the filtering is dead simple. :-)
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"johnb" <johnb@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:915D58F0-8845-4B8F-87DB-3C5EB2CA48C6@xxxxxxxxxxxxxxxx
Hi Allen Browne
I've just downloaded the solution you suggested. How on earth did you get
your brain around that code? I know code is a bit like bricks in a wall; one
brick is like one line of code. How did you approach solving this problem? I
feel a loss as to where start solving a problem like this.
Regards
john
"Allen Browne" wrote:
John, you would need to use the AfterUpdate event of the first combo box to
set the RowSource of the second one.
You may run into problems here: these fields appear to have different data
types (text, number, and date), and it is quite easy to crash Access if you
go altering the data types after the form is open.
It may therefore be better to use a combo for selecting the field, and a
text box for entering the value to match. You can do that quite easily by
downloading the example from here:
Find as you type - Filter forms with each keystroke
at:
http://allenbrowne.com/AppFindAsUType.html
This example is *very* easy to set up: after you copy the code into a
module, you just paste the combo and text box onto any form and set one
property. It figures out what field it can offer on that form, and matches
the value you type after each key press.
BTW, if you really have a field named Date, it is likely to cause you grief.
Date is a reserved word, and Access is likely to confuse it with the today
(the system date.) For a list of other field names to avoid, see:
http://allenbrowne.com/AppIssueBadWord.html
"johnb" <johnb@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:7D3F1335-9663-4362-82CA-8A3A088D2847@xxxxxxxxxxxxxxxx
> Hi all
> On an AXP Form I need to find records by LastName, PostCode, OrderNo > and
> Date. To have 4 comboboxs, 1 for each search seems dead clumky to me. > But
> I'm
> not how marry an Option Group with a Combobox so that depending on the
> Option
> Group selection the Combobox will show the appropriate list.
.
- Follow-Ups:
- Re: use 1 combobox instead of 4
- From: johnb
- Re: use 1 combobox instead of 4
- References:
- Re: use 1 combobox instead of 4
- From: Allen Browne
- Re: use 1 combobox instead of 4
- Prev by Date: Re: Auto populate a form from an open form
- Next by Date: Re: use 1 combobox instead of 4
- Previous by thread: Re: use 1 combobox instead of 4
- Next by thread: Re: use 1 combobox instead of 4
- Index(es):
Relevant Pages
|