VFP Autoincrement Field 
Author Message
 VFP Autoincrement Field

I'd like to have an autoincrementing field (simliar to the ones that
ACCESS has) in VTP, but can't seem to find a function that does this.  

Gads!  Do you have to *CODE* it?  Or is it hidden someplace.

This is just to create a customer number for indexing.  

Any help would be appreciated.  

Thanks.  

-- Larry



Tue, 10 Feb 1998 03:00:00 GMT  
 VFP Autoincrement Field

Quote:
>I'd like to have an autoincrementing field (simliar to the ones that
>ACCESS has) in VTP, but can't seem to find a function that does this.  
>Gads!  Do you have to *CODE* it?  Or is it hidden someplace.
>This is just to create a customer number for indexing.  

Yes, you have to code it (unless I missed something) and I did this
by creating a procedure stored within my database file called
newid() and placing the following in the default box for the ID
numbers for parts, customers, sales, etc :

        newid("tablename")

This procedure looks up that table's last ID number in a lastnums
table that contains the following structure L

        name    (C,20)
        lastnum (C 16)

Newid() then increments that number and uses the new number as
the default within the database. Once it is coded it works
for every table in any form or routine where you append blank.
I originally saw the idea and some code at Foxteach, I could
post my version of it if their is interest.

Later,

Scott Lynn



Thu, 12 Feb 1998 03:00:00 GMT  
 VFP Autoincrement Field

Quote:

> >I'd like to have an autoincrementing field (simliar to the ones that
> >ACCESS has) in VTP, but can't seem to find a function that does this.  
> >Gads!  Do you have to *CODE* it?  Or is it hidden someplace.
> >This is just to create a customer number for indexing.  

> Yes, you have to code it (unless I missed something) and I did this
> by creating a procedure stored within my database file called
> newid() and placing the following in the default box for the ID
> numbers for parts, customers, sales, etc :

>    newid("tablename")

> This procedure looks up that table's last ID number in a lastnums
> table that contains the following structure L

>    name    (C,20)
>    lastnum (C 16)

> Newid() then increments that number and uses the new number as
> the default within the database. Once it is coded it works
> for every table in any form or routine where you append blank.
> I originally saw the idea and some code at Foxteach, I could
> post my version of it if their is interest.

And before everyone gags at the lack of an autoincrementing field
in VFP, remember that this technique gives you a LOT more power and
freedom than a similar field in Access.  Can an Access database have
a field which increments a character field which looks like "A02"
such that it goes through the whole alphabet, then increments the
numeric portion by even numbers like: B02, C02, D02, ... Z02, A04,
B04, C04, ... Z04, A06, etc?  No, it can't.  But it't no great
feat to do the same thing with a stored procedure like Scott
mentions in VFP.

-- Tim



Sun, 15 Feb 1998 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How to retrieving the autoincrement fields value from SQL server

2. autoincrement field through remote views doesn't seem to work

3. Need help with autoincrement fields

4. autoincrement field

5. autoincrement field - Visual Foxpro database and ADO connection

6. Autoincrement a field in a Trigger?

7. Autoincrement?

8. AutoIncrement

9. AutoIncrement

10. Playing WAV file stored in general field (VFP)

11. Question: Field Validation Error Text (VFP)

12. Help querying VFP 7 datetime fields through ADO under Active Server Pages

 

 
Powered by phpBB® Forum Software