Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a calculated field

Status
Not open for further replies.

Roper7

Technical User
Aug 23, 2001
4
0
0
US
I have a table with 20,090 records, and I need to create a Paid amount field for each record by summing 24 fields in each row. Can someone suggest a good way to do this? Would a query or a program be best? I am new to Fox Pro, though I am familiar with Access and have some experience in Visual Basic. Any help would be appreciated. Lee
 
I guess there are many ways but this would work:

ALTER TABLE mytable ADD COLUMN paidamt n(9,2)
REPLACE ALL paidamt WITH fld1 + fld2 ..... + fld24

Jim
 
good reply jim

roper, if you plan to use a data input form you can use the same code under a command button in the form. If you plan to import records and do sums and seq numbers you can do all that in a report.
 
Hi
You can use
Method 1 : Creates a temp table 'myTempDBF'
SELECT *, field1+field2+...+field24 as PAIDAMOUNT ;
INTO DBF myTempDBF from myDBF

Method 2 : Creates a temp Cursor 'myCursor'
SELECT *, field1+field2+...+field24 as PAIDAMOUNT ;
INTO CURSOR myCursor from myDBF

Method 1 creats a file on your harddisk
Method 2 is temporary and vanishes when you close the table ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK :)
 
Jim's and Ramani's solutions are good, but nobody asked the question as to why you want to store a value that you can calculate as needed, one of the core concepts of data normalization. If you're referencing this data in a form let the form create the total.

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top