Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Removing an autonumber field (Access 2002)

    Hi,

    I have a process that adds a new column and makes it an autonumber field using the following code:

    Set tdf = dbs.TableDefs(strTableName)
    Set f = tdf.CreateField("MSID")
    f.Type = dbLong
    f.Attributes = dbAutoIncrField
    tdf.Fields.Append f

    This works fine, however, there is also a field called EducationNumber which is sometimes added as an autonumber. This then makes my code fail as you can't have 2 autonumbers on a table. Can anyone tell me how to remove an change an existing autonumber back to a standard number field (take the auto increment off)?

    Regards,

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Removing an autonumber field (Access 2002)

    You can execute an ALTER TABLE statement:

    dbs.Execute "ALTER TABLE [" & strTableName & "] ALTER COLUMN EducationNumber INTEGER"

  3. #3
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Removing an autonumber field (Access 2002)

    Thanks Hans, that worked perfectly!

Posting Permissions

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