Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid with view as data source
Message
 
To
09/12/1997 18:16:18
Mandy Mccord
Public Interest Breakthroughs, Inc.
Albany, New York, United States
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00064826
Message ID:
00064862
Views:
27
>Ok, this is getting silly. Here's what I'm "trying" to do.
>
>I've created a view, VendorView, which consists of my codes.dbf (lookup display values for use with my tables) with a filter of " codetype='vendor' " so I have a collection of only my vendor codes/display values.
>
>I then created a view, NetworkView, which links a data table, Networks.dbf, containing the following fields:
>
> nid ... primary key
> product... text field
> vendorcode...code for vendor display value from codes.dbf
> numunits ... number field
>
>with my VendorView so I get the display values for my Networks.vendorcode values. On the Update Criteria page of View Designer, I have Networks.nid as the key field, and Networks.product, .vendorcode, and .numunits as updatable fields. The "Send SQL updates" box is checked, SQL WHERE is the default "Key and modified fields", and "Update using" is also the default "SQL UPDATE" option.
>
>I now want to use VendorView as my data source for my Networks grid on a form. I have 3 columns:
> Column1 ... Products (order set on this field)
> Column2 ... Vendor (display value for Networks.vendorcode)
> Column3 ... Number of Units (numunits value)
>
>Column2 contains a combobox control so my users can pick a vendor from a list. I need to display the codes.dbf display value, but save the user's changes to Networks.vendorcode field for the appropriate record.
>
>I can't figure out how to do this without some awkward and probably inefficient coding. And I can't find documentation re: using views as grid sources with comboboxes.
>
>Any words of wisdom out there??? I'm sure this isn't that complex is I knew what I was doing :^)! Any help would be ***incredibly*** appreciated!
>
>Mandy

Mandy -

Try setting the following properties for your combo box:
RowSourceType = sql statement
RowSource = "SELECT cDesc, cID from CODE where codetype='vendor' into cursor zVendors"
Columns = 2
BoundColumn = 2
controlsource = networkview.vendorcode

In the grid, set the properties for the column that holds the combo box
ControlSource = networkview.vendor
bound = .F.
sparse = .T.

Finally, to make sure the display is always right, in the lostfocus method of the combo load the vendor description into the view.
replace vendor with this.displayvalue in vendorview

I think that will get you what you want. Note that combo boxes in grids are tricky. For example, when you are in the combo box, the down arrow will change the selection in the combo box, not advance to the next record in the grid. You can change this behavior by trapping the arrow keys in the KeyPress event of the combo. (But you must know the state of the combo--for example, if the list is "popped", a down arrow should not move to the next record, it should perform its default behavior.)

Somewhere I saw someone doll-up a text box to mimic a combo-box; as you typed in characters it filled in the rest of the text box with the closest matching entry in its "list". I think it was in FoxPro advisor; maybe someone who reads this can point you in the right direction. I think such a control might work better for your application.

- Mark
----------
Mark Bucciarelli
Previous
Reply
Map
View

Click here to load this message in the networking platform