Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem in GRID with calculate column
Message
 
To
30/01/2007 16:14:06
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01190586
Message ID:
01190673
Views:
10
>>>>>There are certain kinds of interface when 'calculated' column is not really calculated :), i.e. interface provides users with tools to make adhoc calculation and save result without caring how it was reached. For example, it may allow to apply random discounts to price, 5% (not right ?), ok then 5% more, 4% more etc. until 'final' result (i.e. satisfactory for a customer on phone) is reached. This way 'calculated' field should be saved, though I'm unsure if it's the case for this thread.
>>>>
>>>>Agree, but this is not calculated :-) this is USER DECIDED what the price must be. And in the report that will look terrible:
>>>>
>>>>Qty        Unit Price   Total
>>>>-----------------------------
>>>>10            10          45
>>>>
>>>>Grrrrrrrrrr
>>>>Better add an additional column with discount where the user can add the discount and keep calculated coluln out of the table :-)
>>>
>>>No, in your example custom price (and total based on it) would be a result of 'calculations', and report could show also unit price and some discount (really calculated) against unit price.
>>>My point was that grid interface could have a column that is 'calculated', from interface standpoint, but data would be saved to table.
>>
>>Then I'll do all my calculations in my CA (just add one additional field where the user can WRITE His/Her totals) make this field NON UPDATABLE and do the calculations for other fields where the users changes the value of this field:
>>
>>This is a rough example, just on top of my head:
>>
>>SELECT Qty, UnitPrice, Discount, (Qty * UnitPrice)*(100-Discount)/100 AS Total
>>       FROM ....
>>
>>
>>Then when the user Change the value of Total:
>>
>>REPLACE Discount WITH (1 - ((Total/Qty) / UnitPrice)) * 100 && I am not sure if this calculation is correct
>>                                                            && but this is only example :-)
>>
>>Then in you table you will have only Qty, UnitPrice and Discount, Total is always calculated.
>
>No problem, it can (and probably should) be saved this way. The point was about interface: 'calculated' column but with controlsource that will be either saved directly or used in calculations before save.

Yep,
but my point is that there is no need of additional Calculated field IN the table. You could have one in the resulted cursor (if you want to change its value :o))
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform