replace field with count variable in foxpro

5 pts.
Tags:
Database programming
FoxPro
SQL
VB
Visual Basic
Hello, in Foxpro 6, I need to replace a field with the count from a memory variable when an invoice # is the same. The database lists the detailed line items of the invoice and the invoice # next to them. So, if invoice 56 had two items, I would need 1 in the count column for item 1 and a 2 in the count for item 2, then reset when the invoice # changes and start again. Sorry for the basic question, I'm just getting the hang of some of this. thanks in advance.

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hello,
I’m not sure I understood what you mean exactly but I suppose you are using SQL queries to read your data.
So I suggest you using a query as the following:

<pre>SELECT (ROW_NUMBER() OVER (ORDER BY YourField ASC)) as MyCounter , FieldA, Fieldb
FROM YourTable</pre>

That will number the returned rows with increments.

E.g.

<pre>1 –result fielda — result fieldb
2 –result fielda — result fieldb
3 –result fielda — result fieldb
</pre>
and so on.

Once you have built your query you can easily compare the results of the <i>MyCounter </i>field to match the one stored in your variable and proescute with your code.

I hope the examples above are clear enough and helpful to you, if it doesn’t please be more specific with table names and any additional data that may clarify exactly your needs.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following