As the original question implies:
>Does anyone know how to establish a field in Visual FoxPro database which acts as an AutoID? For example when a user enters a new record this particular field will automatically increment. I know how to do this in MS Access, but not in FoxPro. Can Anyone help?
>
>Thanks,
>Bob
The best and safest solutions are what Barbara Paltiel and Adam Weisberg suggest:
"Assuming you have 1) a table holding the next Unique ID value for each table and 2) a function that gets the next value from the UniqueID table, you
can put this function into the default value of the the ID field for each table. For example, if your function is NewID(MyTable) then in the Customer
table, with ID "CUSTID" your default value for the CUSTID field would be NewID('Customer')."
I'm just working on a routine that will handle a large number of users and, in order to keep a secure sequential order, I've found that this is the safest approach, to have this kind of function working for you. To add to what Barbara explains, this function should be located in the stored procedures section of the database, and apply the same principle for all the tables that need to store a unique id, simply by calling it from the
default value box of each table.
Gil
For every bug fixed, there is a bigger bug not yet discovered.