Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid: ControlSource - column vs CurrentControl?
Message
From
13/12/2006 10:42:48
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01177136
Message ID:
01177177
Views:
15
>>>>I have a grid that I am trying to display invoice detail records in. My columns are:
>>>>ItemCode, ItemDesc, Qty, Units, Price and Extended Amt.
>>>>ItemCode is a 2-column combo box (0 - Dropdown) with RowSource = PRODUCTS.ItemCode,ItemDesc (so user sees a list of part numbers and descriptions). The grid's ItemDesc, Units & Price columns all point to corresponding fields in my PRODUCTS lookup table. ItemDesc and Units are really just informational - they do not need to be saved in the InvDetail table (invoice line items). But, I want the Price column to display the corresponding PRODUCTS.Price amount *and* update InvDetail.Price with this same value (from PRODUCTS). So, I assume that the Price column's ControlSource should be InvDetail.Price - right? Same for Price's Text1 ControlSource? Also, how do I initially populate the Price column with the matching PRODUCTS.Price value?
>>>
>>>Yes, Price's column controlsource should be InvDetail.Price. You don't need to set textbox controlsource in the designer. Now, are you using buffering and tables directly?
>>>
>>>In your combobox valid event you may put replace price with Products.Price in InvDetail. This would update price column. You may have to call colPrice.refresh() method, though I'm not certain it's necessary.
>>
>>Yes, I do use buffering, so I can easily undo any changes if user cancels...
>>
>>Another issue is that the dropdown's list immediately closes as soon as I type any key. This seems to happen because InvDetail.ItemCode is blank (form's Init inserted a blank InvDetail record as the first line item to appear in the grid). I guess the fact that an EOF occurs in my PRODUCTS lookup table is causing me all this grief :( Maybe I need to add a record to PRODUCTS with a blank ItemCode and a ItemDesc = "select item..."? In fact, I could make the ItemCode = "\ " so it will not be selectable. It's just weird that the exact same combo box outside of the grid does not exhibit these quirks. Then again, I do have other columns that are mapped to PRODUCTS fields...
>
>For some reason I don't like to use fields as RowSource. I prefer to use cursors, e.g. in form's Load (if Products table is not going to change in form's life-time):
>select ItemCode, ItemDesc from products into cursor curProducts order by 1.
>set rowsource type to be 2 alias curProducts. In combo's valid you may also replace InvDetail.ItemCode with the value of the combobox (in addition to updating the price).

I think I have heard others say they prefer cursors too. Just trying to learn - do you have any particular reason why you don't like to use fields?

Also, is there a difference between "6- Fields" and "2 - Alias" for RowSourceType? Say I have a free table, PRODUCTS.DBF. If I want a combo box to be directly populated with fields from this table, is there any difference between these two RowSourceTypes? In both cases, PRODUCTS refers to both the table's alias and its actual name...
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform