Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cross-cou;ling comboboxes in grid?
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00262958
Message ID:
00263017
Views:
31
>Novice question....
>
>How can I update the value in a second grid column based on a selection in the first?
>
>I have an order entry screen with a grid. One column is the product ID and the other is the product description. There is a products table and an orderitems table. Only the product ID will be stored in the orderitems table. Product description is used for reference only.
>
>I would like to use combo boxes in each column. The row source will be the fields ProductID and Description in the products table. The control source field for the productid column will be orderitems.productID.
>
>Here's the challenge: I would like the user to be able to select the desired item by either of the following methods:
>a: If product ID is known, select product ID by incremental search or dropdown list. When selected, the product ID is stored in the orderitems.productID record and the proper product description will appear in the description field.
>b: Select the product by dropdown from the description list. When selected, the proper productID will be displayed in the productID column, and entered in the orderitems.productID record.
>
>I suspect that the code should be entered in the valid event of the combo boxes, and I'll be stuffing the .value property of the productID field. What I'm not sure of is matching the corresponding values of productID and description when selecting and stuffing. Will selecting one move the record pointer in the products table to the desired item? Will I need to refresh the form at that point?
>
>Any suggestions?
>
>Thanks,
>Neil Preston

This is easiest done using a parameterized [?nInvoice] and updatable SQL view of the OrderItems table. The View needs to include a field for the description. Just don't make that field updatable. The SQL example woudl look something like:
create sql view v_orderitems as ;
   select orderItems.*, space(40) as Descript ;
   from OrderItems ;
   where invoice = ?nInvoice ;
   order by LineID
Set the ControlSource of the 1st and 2nd columns to the Item_No and Descript respectively. In the InteractiveChange of each combobox is where I would put code to refresh the other column's Value and DisplayValue.
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform