Discussion:
Incrementing a field
(too old to reply)
jjoseph
2005-11-11 21:22:21 UTC
Permalink
Wanting to know if it possible to set initial value typeN of a field in
record 1 and then increment each record of that field by 5.
exp
field
record 1 1000
record 2 1005
so on

I am very new to foxpro but if it is possible i believe it takes code
which i would be place in the "'with" tab under the replace fields
button
TIA
Josh Assing
2005-11-11 23:35:33 UTC
Permalink
repl all nField with (nInitValue + (recno() -1 * 5) )

What is your real-world issue you're working with?
Post by jjoseph
Wanting to know if it possible to set initial value typeN of a field in
record 1 and then increment each record of that field by 5.
exp
field
record 1 1000
record 2 1005
so on
I am very new to foxpro but if it is possible i believe it takes code
which i would be place in the "'with" tab under the replace fields
button
TIA
--- AntiSpam/harvest ---
Remove X's to send email to me.
Cindy Winegarden
2005-11-11 23:40:43 UTC
Permalink
Hi J,

You can't put code in the Replace Field dialog on the Table menu.

Are you trying to do this process once for a table you have or are you
trying to do this automatically for every new record you are adding to the
table?

Which version of FoxPro are you using? If you're using a newer version of
FoxPro there is an auto-incrementing Integer field where you can set the
initial value and the increment. If you're using an older version of FoxPro
there are ways to do this but you have to write code and call it every time.

If you only want to do it once try the following in the Command window:

Replace All FieldName With StartValue + ((RecNo() - 1) * 5) In TableName
--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
***@msn.com www.cindywinegarden.com
Blog: http://spaces.msn.com/members/cindywinegarden
Post by jjoseph
Wanting to know if it possible to set initial value typeN of a field in
record 1 and then increment each record of that field by 5.
exp
field
record 1 1000
record 2 1005
so on
I am very new to foxpro but if it is possible i believe it takes code
which i would be place in the "'with" tab under the replace fields
button
TIA
jjoseph
2005-11-14 17:06:38 UTC
Permalink
Thanks
This command accomplished my task. I am foxpro 7.0 but used suggested
command line. Looked into auto-incrementing integer but need more
practice in using it. I had the table in order and wanted to renumber
plu's from a point-of-sale database. Now that I have the answer to
this questions I have others I need help with and will start new topic.
Thanks once again

Loading...