Results 1 to 8 of 8
  1. #1
    Mattbro is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    100

    Form sourced to table with autonumber as PK opening to new record

    Hello All,


    I have been 'upgraded' to Access 2010. In my Db I have a form "FrmSent" bound to a table "TblSent". The table has an autonumber as the PK called "ID". I open the form on the click of a button from another form, and at a new record using
    Code:
     DoCmd.GoToRecord acDataForm, "FrmSent", acNewRec
    in the 'On Load' property of FrmSent.
    I need the "ID" box to automatically populate with the new record ID number, but will it? No, it will not! Thus when I close the form, I get the usual 'cannot contain a null value message'. I have messed around with the form, set 'Data Entry' pro[erty to yes, deleted it, rebuilt it....can't get it to work!
    Can anyone throw any light as to what I am doing wrong?
    Many thanks,
    Mattbro

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Are you saying that an AutoNumber field on your form will not populate when you change other fields on a new record and then try and save it?

  3. #3
    Mattbro is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    100
    Right you are. Thats exactly whats happening! Form has table as source, opens to new record....ID stays empty! Flummoxed....

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    It will stay empty until you change another field which will Dirty the record. But you knew that right?

  5. #5
    Mattbro is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    100
    Thats the problem. I can fill in all the other textboxes in the form-each obviously linked to a field in the table, the ID box still does not populate. I try to close the form and I get the null value warning. Don't get it. Never happened before. The autonumber just doesn't appear or seem to generate...... Currently, I don't have a 'save' command in the code. I tried putting one it, but it still gave me the same problem.
    Would it be to do with me coding the form to open at a new record? Is there some property in Access 2010 that I don't know about when linking forms to tables? Should I have the data entry property on the form ticked?

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Try a Compact and Repair first. If that does not resolve the issue then try *importing* your db into a fresh new db and see if the issue follows. http://www.btabdevelopment.com/ts/impnew

  7. #7
    Mattbro is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    100
    Hmm. Exported the data out as excel, deleted the db, started again from scratch, and has worked. Not sure what the issue was, but that's working now. Thanks.
    M

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Thanks for sharing your success and solution.

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

Similar Threads

  1. PK of fields in a form that is sourced by a query
    By accessuser1023 in forum Programming
    Replies: 3
    Last Post: 12-29-2012, 04:55 PM
  2. Replies: 0
    Last Post: 09-17-2012, 03:35 PM
  3. Replies: 9
    Last Post: 09-16-2011, 03:52 PM
  4. Replies: 6
    Last Post: 03-14-2011, 09:37 AM
  5. Replies: 1
    Last Post: 08-27-2010, 05:16 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