I wish to filter the list of items in a combobox (called cbomaterialcode)
based on the value selected by user from the combobox cboPOGroup, during
run-time. For example, when user select the POgroup FIXA, only the
materialcode related to fixed asset be listed in the combobox
cbomaterialcode. The purpose is to reduce the number of items in the list of
the combobox dropdown. How can I best achieve this?
Thanks in advance
Sing Chung
It depends :-)
On your cbomaterialcode.RowSourceType, that is. For instance,
with RSType 3, SQL, you can put an SQL statement directly into
the combo.RowSource, e.g.:
"Select theField From theTable Into Cursor xy"
Then you'd do a cbomaterialcode.Requery() whenever you want to
reequery its RowSource.
So in your scenario, you may want to have a Where condition, either
hard-coded or dynamically in cbomaterialcode.Requery():
Local lcSQL, luValue
lcSQL="Select theField From theTable Into Cursor xy"
If Type('Thisform.cboPOGroup.Value') <> 'U'
luValue = Thisform.cboPOGroup.Value
lcSQL = m.lcSQL + " Where theOtherField = " + Trans(m.luValue)
&& addditional quotes for char values
This.RowSource = m.lcSQL
hth
-Stefan
--
|\_/| ------ ProLib - programmers liberty -----------------
(.. ) Our MVPs and MCPs make the Fox run....
- / See us at www.prolib.de or www.AFPages.de
-----------------------------------------------------------
"Stefan Wuebbe" <stefan...@gmx.de> wrote in message
news:eINIBkGV...@TK2MSFTNGP06.phx.gbl...
You're welcome. "m." is FoxPro syntax for pointing out that the
following name is a variable name, as opposed to a column name.
-Stefan
LOCAL firstname
CREATE CURSOR xx (firstname C(20))
SELECT xx
IF EMPTY(firstname) && This references xx.firstname
IF EMPTY(m.firstname) && This references the local
&& variable firstname
Because of this feature it is good practice to try to use different
naming conventions for variables and field names.