Solved

Visual Fox Pro commands

Posted on 2011-02-13
15
73 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
  • +2
15 Comments
 
LVL 42

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 42

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 42

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
 
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 42

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 42

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

Get Actionable Data from Your Monitoring Solution

Your communication platform is only as good as the relevance of the information you send. Ensure your alerts get to the right people every time with actionable responses. Create escalation rules that ensure everyone follows the process and nothing is left to chance.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
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…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

717 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