Results 1 to 13 of 13
  1. #1
    fuecheefang is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2015
    Posts
    43

    Autonumber after inserting data already *newbie*


    I need help with starting an auto number feature in the table on Project_Id. I initially started the ID with text format so I can enter the specific id's into the table. Now, that Ive entered the 80+ fields, how can I start an auto number in the ID same table.

    thanks. Sorry I am really new to access.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    yes, just add a new field [ProjID] as AUTONUMBER
    save.
    (you can update any sub tables from the OLD id with the new id)

  3. #3
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    You can add an Autonumber field to an existing table.
    Simply go to Design View, add the new field, selecting the Autonumber option. It will automatically number the data you have in there.

  4. #4
    fuecheefang is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2015
    Posts
    43
    Hello JoeM, I tried that as well but it changes the existing numbers Ive manually typed in previously

  5. #5
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Hello JoeM, I tried that as well but it changes the existing numbers Ive manually typed in previously
    That is correct. You have no control of the Autonumber field; you do not have the ability to manually set any values in the Autonumber field. You cannot keep what you have in that field, and convert it to an Autonumber field going forward.

    All the Autonumber field should be used for is to create a unique identifier. If it needs to be something more than that, then you should be using something other than Autonumber - maybe come up with your own identifier. People have created VBA code that do that sort of thing, based on certain criteria.

    That being said, it is generally a good idea to have an Autonumber or some other unique identifier in every table in your database.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    Has your original ID field been used to populate foreign key field of a related table? If it has, then you need to decide whether to retain the original data as PK/FK or to switch the autonumber to PK/FK. Switching will involve updating the related records with the new autonumber values. Whether or not you continue to generate the original custom unique identifier if the autonumber becomes the PK/FK is another decision.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    fuecheefang is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2015
    Posts
    43
    Quote Originally Posted by June7 View Post
    Has your original ID field been used to populate foreign key field of a related table? If it has, then you need to decide whether to retain the original data as PK/FK or to switch the autonumber to PK/FK. Switching will involve updating the related records with the new autonumber values. Whether or not you continue to generate the original custom unique identifier if the autonumber becomes the PK/FK is another decision.
    June7 no my Projects table does not have PK, nor does it relate to any other records in other tables.

  8. #8
    fuecheefang is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2015
    Posts
    43
    Quote Originally Posted by JoeM View Post
    That is correct. You have no control of the Autonumber field; you do not have the ability to manually set any values in the Autonumber field. You cannot keep what you have in that field, and convert it to an Autonumber field going forward.

    All the Autonumber field should be used for is to create a unique identifier. If it needs to be something more than that, then you should be using something other than Autonumber - maybe come up with your own identifier. People have created VBA code that do that sort of thing, based on certain criteria.

    That being said, it is generally a good idea to have an Autonumber or some other unique identifier in every table in your database.
    JoeM, my projects table does not have a PK, and it is not related to any other field in other tables. It does need to be a unique identifier as it needs to keep track of new projects being added. Just confus

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    Then what is the issue?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    fuecheefang is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2015
    Posts
    43
    Quote Originally Posted by June7 View Post
    Then what is the issue?
    I have a set of numbers (project IDs) that were from an Excel Spreadsheet. We now transferred everything to Access, and need to keep those same Project ID's for historical data. We need those id's to remain while having the ability to continue adding new projects into the Access DB.

  11. #11
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    So, what is preventing you from adding new Projects? You should be able to manually enter Project IDs in Access.
    How were these Projects IDs being determined in Excel?
    Are you looking for something automated?
    What structure/rule/criteria do you want to use for these Project IDs?

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    So the original ProjectNo values are just sequential numbers, no alpha characters and you want the autonumber to take over generating new ProjectNo? These ProjectNo values are unique in this table - there are no repeats?

    It is possible to set the value of autonumber field with an INSERT sql action but not with an UPDATE sql action. Create a new table with the required fields then run an INSERT SELECT query to populate this new table. When the data is good, delete old table and rename new table with old name.

    INSERT INTO [Copy of Table1](ID, EventNo, EID, ArrivedTime, Code, CancelledTime) SELECT ProjectNo, EventNo, EID, ArrivedTime, Code, CancelledTime FROM Table1;

    Then run Compact & Repair on db before adding new records.

    80+ fields is quite a few in one table. Possibly you need to normalize data structure.


    As JoeM stated, autonumber is not supposed to be a value that has meaning to users. Supposedly autonumber can generate negative values and not always increasing, although I have never seen either behavior. Cannot rely on autonumber to be gap free.


    Note that field names in the example do not have spaces or special characters/punctuation (underscore would be acceptable exception).
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #13
    fuecheefang is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2015
    Posts
    43
    Quote Originally Posted by June7 View Post
    So the original ProjectNo values are just sequential numbers, no alpha characters and you want the autonumber to take over generating new ProjectNo? These ProjectNo values are unique in this table - there are no repeats?

    It is possible to set the value of autonumber field with an INSERT sql action but not with an UPDATE sql action. Create a new table with the required fields then run an INSERT SELECT query to populate this new table. When the data is good, delete old table and rename new table with old name.

    INSERT INTO [Copy of Table1](ID, EventNo, EID, ArrivedTime, Code, CancelledTime) SELECT ProjectNo, EventNo, EID, ArrivedTime, Code, CancelledTime FROM Table1;

    Then run Compact & Repair on db before adding new records.

    80+ fields is quite a few in one table. Possibly you need to normalize data structure.


    As JoeM stated, autonumber is not supposed to be a value that has meaning to users. Supposedly autonumber can generate negative values and not always increasing, although I have never seen either behavior. Cannot rely on autonumber to be gap free.


    Note that field names in the example do not have spaces or special characters/punctuation (underscore would be acceptable exception).
    Thanks June7, ill give this a shot and give you guys an update in a day or two. I appreciate all the quick responses.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Inserting Data
    By dandoescode in forum Programming
    Replies: 6
    Last Post: 06-07-2012, 09:17 AM
  2. !!Please Please Help!! Inserting my Data
    By dinorbaccess in forum Access
    Replies: 9
    Last Post: 01-08-2011, 05:24 AM
  3. Inserting records into tables with autonumber
    By LAazsx in forum Import/Export Data
    Replies: 1
    Last Post: 12-13-2010, 11:55 PM
  4. Inserting data through forms
    By nivi30 in forum Forms
    Replies: 1
    Last Post: 12-17-2008, 07:57 AM
  5. Inserting data in new colums
    By wasim_sono in forum Queries
    Replies: 2
    Last Post: 02-28-2006, 01:11 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
  •  
Other Forums: Microsoft Office Forums