Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Filtering of combobox rowsource items based on the value selected on another combobox

456 views
Skip to first unread message

Hii Sing Chung

unread,
Dec 2, 2008, 5:05:34 AM12/2/08
to
Hi,

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

Stefan Wuebbe

unread,
Dec 2, 2008, 5:29:12 AM12/2/08
to

"Hii Sing Chung" <sing...@hotmail.com> schrieb im Newsbeitrag
news:8669C5E9-29BB-4269...@microsoft.com...

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
-----------------------------------------------------------


Hii Sing Chung

unread,
Dec 3, 2008, 2:06:40 AM12/3/08
to
Thanks, Stefan.
Just wonder, is the "m" in the m.lcSQL refer to "me" or "my"?

"Stefan Wuebbe" <stefan...@gmx.de> wrote in message
news:eINIBkGV...@TK2MSFTNGP06.phx.gbl...

Stefan Wuebbe

unread,
Dec 3, 2008, 4:40:30 AM12/3/08
to
"Hii Sing Chung" <sing...@hotmail.com> schrieb im Newsbeitrag
news:3F3A5B4D-CFF9-4770...@microsoft.com...

> Thanks, Stefan.
> Just wonder, is the "m" in the m.lcSQL refer to "me" or "my"?

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

Jack Jackson

unread,
Dec 3, 2008, 1:44:40 PM12/3/08
to
One reason for using the m. prefix is that when resolving a name (in
situations where a field name is legal), VFP will look first for a
field in the current workspace, and if there is no such field there
will then look for a variable of that name.

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.

0 new messages