Results 1 to 8 of 8

Thread: How do I create an AUTONUMBER field?

  1. #1

    Thread Starter
    Lively Member benski's Avatar
    Join Date
    Sep 1999
    Location
    UK
    Posts
    126

    Post

    Help!

    I can't work out how to create an autonumber field!! I think it is set is the Attributes field, but that always seems to be read only!

  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    what DB file type are you using? You should be able to specify this in the app that manipulates the DBs

  3. #3
    New Member
    Join Date
    Jan 2000
    Location
    Erie,CO,USA
    Posts
    3

    Post

    It is correct that this is a database dependent problem. Microsoft access is the only db I know of that has a datatype known as autonumber. You set this as the datatype of the field when you are defining the table. SQL server has something similar but it is referred to as an Identity column. Oracle has no such built in datatype for a field. You instead need to use triggers along with something called a sequencer.

  4. #4

    Thread Starter
    Lively Member benski's Avatar
    Join Date
    Sep 1999
    Location
    UK
    Posts
    126

    Post

    Sorry, dumb question!

    If fld is a Field object then:

    fld.Type = dbLong
    fld.Attributes = dbAutoIncrField

    gives you an Autonumbered Long Integer field.

    Doh!

  5. #5
    Addicted Member
    Join Date
    Oct 1999
    Location
    NY, USA.
    Posts
    240

    Post What is an "autonumber field"

    Hi Could you clearly explain to me what is an Autonumber field ?

    Thanks
    Omar
    [email protected]
    http://omar.caribwalk.com
    To God Be The Glory

    I see Tech People ...

  6. #6

    Thread Starter
    Lively Member benski's Avatar
    Join Date
    Sep 1999
    Location
    UK
    Posts
    126

    Post

    Autonumber fields:
    are of data type Long Integer
    cannot contain duplicate values
    automatically set their value to a long integer when a new record is added
    are usually used as the primary key for a table.

  7. #7
    Addicted Member
    Join Date
    Oct 1999
    Location
    NY, USA.
    Posts
    240

    Post Re Autonumber field

    Sorry to be a bother, Why is it used, What is it's main purpose?

    Thanks
    Omar
    [email protected]
    http://omar.caribwalk.com
    To God Be The Glory

    I see Tech People ...

  8. #8

    Thread Starter
    Lively Member benski's Avatar
    Join Date
    Sep 1999
    Location
    UK
    Posts
    126

    Post

    No problem, but you'll have to excuse me- my explanation may not be very concise.

    Basically if you want to link say a table of customers with a table of orders made by those customers, you could index your customer table with an autonumber field, eg:

    ID, CustomerName (etc)
    1 John Smith
    2 Joe Bloggs
    3 Fred Flintstone

    Each time you add a customer, the record is allocated a unique number.

    Now, in the orders table, we might have:

    OrderNo, PartNo, CustomerNo (etc)
    1,35,1
    2,38,1
    3,35,3 etc

    In the orders table, the data in the fields PartNo and CustomerNo refer to fields in other tables which could be autonumber fields. The data tells us that John Smith has ordered PartNo 35 and 38 and Fred Flintstone wants PartNo 35.

    Hope this helps



    Edited by benski on 02-24-2000 at 07:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width