Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid: ControlSource - column vs CurrentControl?
Message
 
 
À
13/12/2006 09:59:47
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01177136
Message ID:
01177164
Vues:
10
>>>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).
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform