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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

listbox notupdated as per choice in optiongroup 1

Status
Not open for further replies.

foxup

Programmer
Dec 14, 2010
328
CA
Hi All,

I have 3 choices in an option group. When the user chooses option1 I want the items in a listbox (next to the option group) filtered accordingly.

It doesn't seem to 'filter" the items properly. I have in my "click" procedure:

CASE THISFORM.optiongroup1.VALUE=3 AND THISFORM.text11.VALUE="RES"
SET FILTER TO SUBSTR(servspeed.typnspeed,1,3)="RES"

please help.

thanks,
 
Well, you can't SET FILTER on the items in a listbox. You can only SET FILTER to the underlying table or cursor.

If your listbox has a RowSourceType of 6, it means that the contents of the list is bound to a table or cursor. In that case, make sure that the work aread of the table / cursor in question is selected at the time you execute the SET FILTER. Then, call the listbox's Requery() method. Tht way, the listbox will only show the contents of the filtered cursor.

If the listbox has a different RowSourceType, you will have to re-populate it after setting the filter. How you do that depends on the RowSourceType.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
OK, so I did:

my rowsourse is 6
I did a "select servspeed" before the "set filt" command

How do I " Then, call the listbox's Requery() method." ??

please help


thanks,
 
I have the following:
CASE THISFORM.optiongroup1.value=3 AND ALLTRIM(thiSFORM.text11.VALUE)="COM"
select servspeed
set FILTER TO ALLTRIM(servname)="DRY LOOP" AND ALLTRIM(servtype)="COM"
ThisForm.combo1.Requery()

in my click procedure of the optiongroup but combobox is still not showing the proper data. What am I missing?

Please help.

Thanks,
FOXUP!
 
Foxup,

Try adding this line to the end of the above code:

thisform.combo1.ListIndex = 1

I suspect the filter is being correctly set, but the listbox is still sitting on a record that is outside the filter. The above should fix that.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
I want the items in a listbox
ThisForm.combo1...

Is this a Combobox or a ListBox?

The code you show above suggests that it is not a ListBox, but instead a ComboBox.

The first thing I would do would be to put a SET STEP into the OptionGroup Method to ensure that it is executing as intended by examining the code execution in the TRACE Window.

And then if the intended part of the code did indeed execute, before the execution of the REQUERY() I would, in the Command Window, do a BROW NORM to examine the results of the FILTER to ensure that it also resulted in the desired records.

Finally, after confirming that all of the above worked as intended, I would run the REQUERY() or use alternative code to change what was displayed.

Good Luck,
JRB-Bldr


 
JRB-Bldr, good point. I hadn't noticed the transition from listbox to combo box.

Foxup, perhaps you could clarify: is it a listbox or a combo box? Although they work pretty much the same, there might be some subtle difference that is preventing your code from working.

Another point: If it is indeed a combo box, you might get a better result (in this case) if you set its Style property to 2.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Hi Mike,

perfect. that works. BUT i think I'm losing my mind! I now get the "cannot access the selected table" error.

I'm losing my brain cells I think.

Any simple help/fix?

thanks,
FOXUP!
 
everything works fine now.

I had some other code doing some other stuff somewhere else...arrrrgggghhh!!


Thanks Mike. Star for U. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top