Results 1 to 10 of 10
  1. #1
    writteninr3d is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2011
    Location
    New Zealand
    Posts
    10

    Adding field in form that auto-increments on record creation

    Somebody please help I am so lost...



    I want to create a field in a form that auto-populates with an autoincremented number. All my tables are set up correctly with primary keys etc, I just don't know which control to use or how to use it to make this work!

    This is probably really basic, surely someone must know the answer...

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    To keep the record straight, *fields* are in records of tables and *controls* are on forms. Maybe this link will help: http://www.baldyweb.com/CustomAutonumber.htm

  3. #3
    writteninr3d is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2011
    Location
    New Zealand
    Posts
    10
    Thanks RuralGuy for your post. I checked out the link, and I'm not after anything fancy like 2006/001, just a simple 1 2 3 etc.

    I am talking about a control in a form sorry, not a field in a table. When I throw a text box control into my form, and I select the source of my data (ContID, PK of the Contract table with Field Size = Long Integer and New Values = Increment.

    I select this data using the Record Source drop-down, which is in the Data tab of the Property sheet for the text box control.

    But when I try to run the form, the textbox is prefilled with #Name?. It may be important to note that the Contract table currently has no values inserted into it.

    Am I making more sense now? Any idea what I'm doing wrong?

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,746
    Are you trying to populate your table from a Form?
    If not, please describe exactly what you're trying to achieve. There may be other methods/options.

  5. #5
    writteninr3d is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2011
    Location
    New Zealand
    Posts
    10
    Yes I am, that's exactly what I'm trying to achieve

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,746
    I don't have Acc2007, I have 2003, so the terminology may be a little different.

    Instead of trying to build something from scratch at the moment, go to the Forms screen and let Access build you a Form based on a table. Select the table you want and choose a form type.

    You want a bound form at this point, so let Access do the work. If you have already defined the tables, the PK etc, then Access will generate a form for you instantly.

    Give it a try. Good luck.

  7. #7
    writteninr3d is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2011
    Location
    New Zealand
    Posts
    10
    Form Wizard works. Access 2007 is a major overhaul, so there's no forms screen, but there is still the 'wizard' and 'from scratch' options.

    It would still be good to know how to do this from scratch at some point - but I think for now this will have to do. Thanks orange.

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,746
    Here's a tutorial for the basic stuff.
    http://office.tizag.com/accessTutorial/accessforms.php

    There are others out there on google somewhere, but I found this
    http://office.microsoft.com/en-us/ac...010232684.aspx

  9. #9
    writteninr3d is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2011
    Location
    New Zealand
    Posts
    10
    I've managed to create the form, but the table isn't being populated from it. The form is only able to scroll between entries I make manually in Datasheet View. Any ideas?

  10. #10
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,746
    Did you look at the basic form tutorial?
    When you add data and go to the next record, are you saying the record(data) is not being saved?

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

Similar Threads

  1. Replies: 63
    Last Post: 01-25-2013, 05:20 AM
  2. Auto fill field upon New Record selected
    By NOTLguy in forum Programming
    Replies: 27
    Last Post: 12-05-2010, 05:12 PM
  3. Form will not save after adding a field
    By avarusbrightfyre in forum Forms
    Replies: 1
    Last Post: 08-20-2010, 06:53 AM
  4. Replies: 1
    Last Post: 03-29-2010, 04:11 AM
  5. Replies: 0
    Last Post: 10-14-2009, 02:44 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