Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Jez Enefer-Mills
  Where is Jez Enefer-Mills?
 Cornwall
 United Kingdom
 Jez Enefer-Mills
 To: Moose Taylor
  Where is Moose Taylor?
 Oxford
 United Kingdom
 Moose Taylor
 Tags
Subject: RE: how to generate running id
Thread ID: 33675 Message ID: 33731 # Views: 3 # Ratings: 0
Version: Visual FoxPro 8 Category: Forms
Date: Tuesday, December 02, 2003 5:22:08 PM         
   


> If you have a separate table with 2 columns
> [Tablename] char(20) and [Id] int(4)
>
> Use this table to store the next Id. (Get the value to update your Id table from the Reccount() from the calling table)
>
> Hope that helps?
>
> John Taylor MCP
> (You can't polish a turd)


But what if several people use the app at the same time ...... and only one person decides not to use the created new record after all.

You can't really roll back the number as you don't know where in the sequence it is.
The only way that I see you can do this is to have a table that contains all the numbers for the ID .. say from 1 to 10,000.. you will also need a field that shows the number is used.

index the table on the used field to make sure that unused number are at the top of the table.

Now when you click on the 'ADD' button call your ID table, search for the first unused number store it to a varible and mark it as used.

You can now add this number to your main table as your ID number.

If you wish to cancel this record before saving just open your ID table locate the ID number and mark the record as unused.

This is not really the way to go, I recommend you stick to the autoinc.

Jez

ENTIRE THREAD

how to generate running id Posted by Manisha Sathe @ 12/1/2003 6:03:58 PM
RE: how to generate running id Posted by Eric den Doop @ 12/1/2003 6:12:45 PM
RE: how to generate running id Posted by Manisha Sathe @ 12/2/2003 4:16:41 PM
RE: how to generate running id Posted by Moose Taylor @ 12/2/2003 4:23:52 PM
RE: how to generate running id Posted by Jez Enefer-Mills @ 12/2/2003 5:22:08 PM
RE: how to generate running id Posted by Moose Taylor @ 12/2/2003 5:36:12 PM
RE: how to generate running id Posted by Jez Enefer-Mills @ 12/2/2003 5:45:02 PM
RE: how to generate running id Posted by Moose Taylor @ 12/2/2003 5:47:12 PM
RE: how to generate running id Posted by Moose Taylor @ 12/2/2003 5:51:25 PM
RE: how to generate running id Posted by Jez Enefer-Mills @ 12/2/2003 5:55:21 PM
RE: how to generate running id Posted by Eric den Doop @ 12/3/2003 12:55:22 AM
RE: how to generate running id Posted by Manisha Sathe @ 12/3/2003 10:29:26 AM