Solved

Visual Fox Pro commands

Posted on 2011-02-13
15
28 Views
Last Modified: 2016-05-30
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
Comment
Question by:ViennaWaitts
  • 5
  • 4
  • 3
  • +2
15 Comments
 
LVL 41

Accepted Solution

by:
pcelba earned 50 total points
ID: 34884791
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
 

Author Comment

by:ViennaWaitts
ID: 34884812
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
 

Author Comment

by:ViennaWaitts
ID: 34884840
Tried again - found MY error.  Got it.  Thank you very much.  I already LOVE Experts Exchange!
0
 
LVL 41

Expert Comment

by:pcelba
ID: 34884850
You are welcome!

BTW, what was the problem?
0
 

Author Comment

by:ViennaWaitts
ID: 34884859
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
 
LVL 41

Expert Comment

by:pcelba
ID: 34884875
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
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 34885662
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 27

Expert Comment

by:CaptainCyril
ID: 34885936
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
 
LVL 41

Expert Comment

by:pcelba
ID: 34887042
The answer is in the question already: "This is a file in an accounting program"
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 34889036
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
 

Author Comment

by:ViennaWaitts
ID: 34890524
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
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 34890759
In some cases it is faster to run a command on the data than do it via the interface. :-)
0
 

Expert Comment

by:EE_AutoDeleter
ID: 41623197
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
 
LVL 41

Expert Comment

by:pcelba
ID: 41623198
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now