Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto Number 1

Status
Not open for further replies.

lashwarj

IS-IT--Management
Nov 1, 2000
1,067
US
How do I get a field to auto number
 
Hi,
Read in this Link....
How to organize auto-increment key field in VFP?
faq184-259
If this is not enough, can suggest much more ways... ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK :)
 
there isnt a easier way to do this LOL
 
Hi...
In your save button, you can add the following code, to get this implemented quickly.

LOCAL lcAlias, lnAuto
lcAlias = ALIAS() && used to store back default alias
lnAuto = 0

SELECT 0
USE myTable ORDER myKey AGAIN && myKey is AutoNumber Field
GO BOTTOM
lnAuto = 1+myKeyField && auto number field
USE

SELECT lcAlias
myKeyField = lnAuto

... proceed to write....
Remember to put the above codes within the folds of locking routines so that the number is not used by another in the mean time.

I am using the above approach in many of my DBFs
Note you are using the DBF again so that the current DBFs pointer is not gtting moved and the rlated consequences.

ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK :)
 
Another way is to have a free table with one record in it.
Open the free table and incriment the field by one.
If you add a year and month field to it you can also use it for invoice numbers.
This routine will automatically reset the Year/month/invoice field each month.

David W. Grewe
Dave@internationalbid.com
ICQ VFP ActiveList #46145644
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top