Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Lookup combo in grid with conditional row source
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Lookup combo in grid with conditional row source
Miscellaneous
Thread ID:
00671343
Message ID:
00671343
Views:
35
Hi all,

I'm trying to have a combo box show a descriptive value while returning a foreign key based on a conditional set of records from the lookup table.

The conditions are based on fields on the current record, so I am using an sql row source in the combo box that includes the needed values in its WHERE statement. I can get the proper row source records to be selected by firing the combo's requery() in its refresh() method, which is fired by the grid's AfterRowColChange().

The problem is getting the combo to show the correct descriptive value and to do this consistently, whether you have selected the combo or not. I suspect the culprit is how I'm firing the requery() and how to coordinate
this with the normal refresh process. Interestingly, if I put an identical combo outside of the grid and just refresh it from the AfterRowColChange(), it seems to work perfectly.

The details follow: (only non-default values of the combo)

BoundColumn: 3
ColumnCount: 6 && to show the condition fields to make sure it worked)
ColumnWidths: 100,15,75,15,75,75
Controlsource: devaeres_v.rat_id
Init Event: (fills RowSource given length of SQL statement. see below)

Refresh Event:
this.Requery()
DODEFAULT()

RowSource: (filled by Init() below)
RowSourceType: 3- SQL

Init():
l1 = 'select rat_title, rat_value, rat_id, rat_type, rat_fk, fk_table from devarate into cursor cbocRat_id '
l2 = ' where rat_type = devaepo_v.epo_type .and. rat_fk = devaeres_v.res_id .and. fk_table = "DEVARESP" order by rat_value'
this.RowSource = l1 + l2

Narrative: Each record in the grid needs to be rated. I want the rating title to be displayed, but the rat_id saved on each record. The choices for each rating are limited by three conditions. It is sort of like rating products, and if one product is a "bicycle" you would have rating choices like "Slow, Fast, Hypersonic". If the next product was "apple", you'd want different rating choices like "Tasty, Tart, Juicy". Each time you go to a new product, you'd want the combo to offer only the appropriate rating choices and save the rat_id for whichever was selected.

My apologies for the lengthy presentation, but I've spent hours going in circles on this. Any thoughts would be greatly appreciated.

Larry
Larry Tucker
Next
Reply
Map
View

Click here to load this message in the networking platform