Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Vfp50 - Auto Numbering
Message
From
21/04/1997 11:35:38
 
 
To
21/04/1997 10:03:25
Larry Long
ProgRes (Programming Resources)
Georgia, United States
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00029060
Message ID:
00029089
Views:
33
>>>I am trying to have new records AUTO NUMBER. My method
>>>is to index on a unique number field and add one number and that is the new number for the next record.
>>>Having problems like this...
>>>the first user adds a record and the computer issues a number 3, at the same time the second user adds a record and the computer issues a number 4. Then first user decides to abort and the second user saves.
>>>Now the second user has the number 4 for it's AUTO NUMBER and there is not a number 3 because the first
>>>use did not save. How can I best do a AUTO NUMBER system?
>>
>>The common way to create unique record id (number) is following:
>>1. System contains table 'Setup' with 2 fields: TableName C, Counter I.
>>2. When user requests for new record id, he runs procedure to:
>>- go to Setup and locate record by specific Tablename,
>>- lock this record (RLOCK),
>>- increment counter by 1,
>>- use ne counter for INSERT command,
>>- unlock Setup record.
>
>Also, you need to do what Edward said AFTER the user has confirmed the entry
>
>Some code that you might want to use..
>
>STORE .F. TO ok2save
>SELECT counterdbf
>DO WHILE .T.
> if rlock()
> repl counterdbf.counter with counterdbf.counter+1
> unlock
> m.counter=counterdbf.counter
> ok2save=.T.
> exit
> else
> clear type
> wait window 'Waiting for system file, press [ESC] to cancel..." timeout 2
> if lastkey()=27
> exit
> endif
> endif
>enddo
>
>if not ok2save
> =messagebox('User abort...",0)
>else
> INSERT INTO targetdbf FROM MEMVAR
>endif


thanks for the code Larry... I will try it...
Robert Keith
Independent Developer
San Antonio, Texas
E-mail address:
rebelrob1@yahoo.com
Previous
Reply
Map
View

Click here to load this message in the networking platform