Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 91
  • Last Modified:

Visual Fox Pro commands

Hello - I am not a programmer but know some rudimentary commands to be able to fix Fox Pro files.  My problem is I want to change a field's contents to be a fixed percentage of another field in the file.  Field A = 5.00  so I want Field B to reflect 0.02 of Field A so 0.1..  I cannot use a replace command as I do not know how to phrase it so it correctly calculates.  This is a file in an accounting program.
Would greatly appreciate assistance so I do not have to manually change 5,000 lines!
Thank you.
0
ViennaWaitts
Asked:
ViennaWaitts
  • 5
  • 4
  • 3
  • +2
1 Solution
 
pcelbaCommented:
You need just two commands:

USE YourTable
REPLACE ALL FieldB WITH FieldA * 0.02

or SQL command:

UPDATE YourTable SET FieldB = FieldA * 0.02
0
 
ViennaWaittsAuthor Commented:
Simple for you, yes, for me, not so much.  I just attempted it but nothing changed.
I opened the file and then Cntrl-W to close window.  In the command box I typed what you had (with the proper field names) and got nothing.  Am I missing some punctuation?
0
 
ViennaWaittsAuthor Commented:
Tried again - found MY error.  Got it.  Thank you very much.  I already LOVE Experts Exchange!
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
pcelbaCommented:
You are welcome!

BTW, what was the problem?
0
 
ViennaWaittsAuthor Commented:
I am embarrassed to tell you I typed the wrong field name.  
I have already applied it and it saved me HOURS.  Thank you again!
0
 
pcelbaCommented:
It can happen to everybody... But it should report an error message (or update the wrong column which is the worst scenario).

Bye
P.C.
0
 
CaptainCyrilFounder, Software Engineer, Data ScientistCommented:
Why would you save a calculated field in a table?

You can always do that in a report form or a grid by using a calculated column.

FieldB = FieldA * 0.02

OR

SELECT field1, field2, field3, fieldA, fieldA*0.02 AS fieldB INTO CURSOR temp
COPY TO report TYPE XLS

OR

REPORT FORM MyReport

When you calculate on the fly, it's always accurate.
0
 
CaptainCyrilFounder, Software Engineer, Data ScientistCommented:
If you are using a BROWSE window you can also do this:

SELECT tablename
BROWSE FIELDS fieldA, fieldB = fieldA*0.02

This way you don't have to calculate the field inside the table and worry if they were properly updated or not.
0
 
pcelbaCommented:
The answer is in the question already: "This is a file in an accounting program"
0
 
Olaf DoschkeSoftware DeveloperCommented:
I agree, pcelba.

Questions Only Vienna Waitts can answer are therefor:
1. Why does the accounting software not put the correct value into FieldB in the first place?
2 Is it correct to replace all values of FieldB with 0.02*FieldA? You might only want to change a portion of the data, not all records.

Bye, Olaf.



0
 
ViennaWaittsAuthor Commented:
Thank you all for the assists.  Pcelba took care of it for me.  I was just uncertain about the commands as some require characters like quotes or what not.
To answer Captain Cyril - I am updating/correcting data in a file so it does not have to be done through the user interface which would take hours and hours and hours.  FYI
Thanks, Olaf, for your input as well.
0
 
CaptainCyrilFounder, Software Engineer, Data ScientistCommented:
In some cases it is faster to run a command on the data than do it via the interface. :-)
0
 
EE_AutoDeleterCommented:
I've requested that this question be deleted for the following reason:

                           
No comment has been added to this question in more than 21 days, so it is now classified as abandoned and is now flagged for deletion.


If there is a valid solution, please OBJECT and indicate the comments that are, or would otherwise lead to, a solution.


Use the specific format https:#axxxxxxxx for comment ID(s).


Also, please don't object simply because the author did not respond to your comment. While we understand this is frustrating, unfortunately we cannot force the author to return to the question. Unless you feel you have presented a valid, verifiable solution we'll simply delete the question.


Experts-Exchange Auto Deleter
0
 
pcelbaCommented:
It is clearly stated by the author: "Got it. Thank you very much.  I already LOVE Experts Exchange!"

The correct answer was this one: https:#a34884791

Others can decide whether to value the additional discussion.
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

  • 5
  • 4
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now