Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to filter data in the dropdown list? 2

Status
Not open for further replies.

Mandy_crw

Programmer
Jul 23, 2020
578
PH
Hi everyone... i have a form the has pageframe, in page 1 i have a dropdown list named CboIdnum which has a source of cursor that is already defined in the load event of the form. My question is i need to filter the dropdown list, I know that is easy to filter using SELECT, i tried creating a procedure CboIdnum.init() and putting my SELECT and WHERE, but it still shows the cursor previosly defined in the LOAD event. Please help.... Thanks and God Bless...
 
Having said that, I'm curious to know why your second SELECT didn't work. Are you sure that you correctly set the combo's RowSource to the new cursor, that is, the one created by that second SELECT?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Well, Mandy, show your select, show your load and how you bind data to the combobox, what settings you do to it. There are a lot of ways you can get a list into a combobox and it matters what you do to make the appropriate change. You seem to think you told us the most important and essential information, but you didn't. So you likely deem details unimportant that actually are making the difference. You are at a stage you should already know yourself what to do, because this seems to me like a problem you already had earlier for another similar situation.

Also, you got a list into the combobox in the first place. The steps to do are known to you.

To demonstrate why it matters how you bind data:

For example, if you use additem to put items into a combobox, then changing the workarea or even filtering it won't have any effect. Just like when you make a copy of a page and then write something on the original, do you really expect that change also to appear on the copy?

Or, if you SELECT into yet another workarea alias name, and the combobox is still bound to the first select result alias name, do you really expect that to change the combobox?

If we don't know everything you do in code and properties to the combobox, we can't really help. So like so often, please tell more, we're not in your head nor on your computer.

Chriss

PS: I'm not even sure you think of filtering the data you already have, like Tore's solution with SET FILTER could do (depending on how you bind data to your combobox). If you filter the data you already have in the combobox, you won't be able to change from names starting with A to names starting with B, to give an example. Because names starting with B are not within names starting with A.

So you're already on a good way with doing a query, now you just need to get this to the same combobox again. And, well, you managed to do this with the first query result from load. What's hindering to get the same thing done twice?
 
Hi Chriss... I have this in the load event..

SELECT ALLTRIM(UPPER(sname)) + ", " + ALLTRIM(PROPER(fname)), idnum FROM tsulat ORDER BY sname, fname INTO CURSOR PgMntCbo

then in one of the pages of my pageframe i have a CboIdnum(1), that should be dynamic, evertime another combobox(2) is selected, it will filter the combobox according to selected item in the combobox(2) I have this code in the page..

PROCEDURE cboIdnum.GotFocus()

SELECT PADR(ALLTRIM(UPPER(sname)) + ", " + ALLTRIM(fname),25), idnum FROM tsulat where tsulat.ay = selected item in the combobox(2) ORDER BY sname, fname INTO CURSOR PgMntCbo

WITH This
.Requery()
.Refresh()
ENDWITH

ENDPROC
This is what i have done... Thanks for you help in advanced.....God bless...
 
Good,

the choice of GotFocus is okay, you could already change the data of CboIdnum in the interactivechange of the other combobox. Let's think through the advantages and disadvantages.

Using CboIdnum.GotFocus has one advantage that you change the bound data just in time, when the user wants to use it to make another choice. The only case that could play a role is if the choice of the other combobox makes the currently selected item in CboIdnum invalid, because it's an item that doesn't fulfill the condition tsulat.ay = selected item in the combobox(2). Then you could end up with a discrepancy.

One way to better control this is to disable controls, since CboIdnum depends on the choice in the other combobox(2), you could disable CboIdnum when the form starts and only enable it, when the user has made a choice in the other combobox(2). Or you give in fully to the dependency of the two comboboxes, which means the scope of the encapsulation and separation of concerns thought of (object oriented) programming becomes the pair of comboboxes, which makes it okay that one combobox controls or influences the other. Then you could do a service to the user and at the time the initial choice is made, in the interactive change, you don't only enable the CboIdnum, you also fill in the data that fits and you make the top record the selected item, which may be the most probable choice.

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top