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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically generating IDs

Status
Not open for further replies.

abbyanu

IS-IT--Management
Jan 18, 2001
82
US
Hi. I'd like to automatically generate IDs for the primary keys in the data entry screen when the user adds a new record.

Any hint on how I can go about this? I would like to use a sequence like 0001, 0002, etc.

Many thanks. Abby.
 
1. Follow the link faq184-259
2. If you do not want to follow the suggestion in that link... then..
** This File opening can be done in Data Environment
USE myFile ORDER myPrimaryKey AGAIN IN 0 ALIAS myKeyCount

and then you can put the following codes in a suitable place where you want to add... say in the save button...
*************************
GO BOTTOM IN myKeyCount
LOCAL cMyKey, nMyKey
cMyKey = myKeyCount.myPrimaryKey
nMyKey = VAL(cMyKey) + 1
cMyKey = RIGHT("0000"+ALLTRIM(STR(nMyKey)),4)
***************************
SO THE VALUE IN cMyKey IS YOUR NEXT KEY. Hope you get the idea.
ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
 
many thanks, ramani. will try this. abby.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top