- Local time
- Today, 10:01
- Joined
- Feb 19, 2013
- Messages
- 16,966
Thought I would just put up this simple example for FAYT for a combo on a continuous form/datasheet.
It is based on a similar principle to the cascading combo examples for continuous forms/datasheets I have provided in the past.
It involves using the combo change event to apply a 'Like' criteria to the combo rowsource and then removing the criteria when exiting the combo. Bu doing this the values displayed in the other rows are not affected.
Changing the rowsource effectively involves a requery of the data on each change which might have performance issues for those with very large datasets (10's of thousands of records) and/or slow connection to the back end.
I did trying working with the combo recordset filter instead to avoid the need to reload data, but without success. It would appear the combo recordset cannot have filters applied or assigned a new recordset - at least not within the change event.
To use, simply start typing and select one of the listed items. This example looks for all occurrences of what has been typed because of the initial '*'. In real life it is probably not required and if only occasionally required users can be trained to enter the initial *. Which is probably worthwhile doing anyway because users can then search for something like sm*plc (in this example anyway).
There is a second version of the form which applies criteria to multiple columns (just two in this example) but can easily be extended to more columns and different rules (such as using AND rather than OR)
Note: Other than the event code, the auto expand property of the combo has to be set to No
Note2: Just for fun, I left aligned the dropdown button in the first example. So do not adjust your set. I did this because for single column data with a wide variety of widths, all that whitespace can result in users selecting the wrong dropdown since it can be a long way away. It doesn't work so well for multi column combos as those columns get reversed as well.
It is based on a similar principle to the cascading combo examples for continuous forms/datasheets I have provided in the past.
It involves using the combo change event to apply a 'Like' criteria to the combo rowsource and then removing the criteria when exiting the combo. Bu doing this the values displayed in the other rows are not affected.
Changing the rowsource effectively involves a requery of the data on each change which might have performance issues for those with very large datasets (10's of thousands of records) and/or slow connection to the back end.
I did trying working with the combo recordset filter instead to avoid the need to reload data, but without success. It would appear the combo recordset cannot have filters applied or assigned a new recordset - at least not within the change event.
To use, simply start typing and select one of the listed items. This example looks for all occurrences of what has been typed because of the initial '*'. In real life it is probably not required and if only occasionally required users can be trained to enter the initial *. Which is probably worthwhile doing anyway because users can then search for something like sm*plc (in this example anyway).
There is a second version of the form which applies criteria to multiple columns (just two in this example) but can easily be extended to more columns and different rules (such as using AND rather than OR)
Note: Other than the event code, the auto expand property of the combo has to be set to No
Note2: Just for fun, I left aligned the dropdown button in the first example. So do not adjust your set. I did this because for single column data with a wide variety of widths, all that whitespace can result in users selecting the wrong dropdown since it can be a long way away. It doesn't work so well for multi column combos as those columns get reversed as well.