>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
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').
Your function can cover checking for duplicate IDs and other problems automatically. This method works even if you are using 'APPEND BLANK' in the command window.
HTH