Results 1 to 5 of 5
  1. #1
    dyy is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2011
    Posts
    2

    Unhappy how to trigger access to set autonumber for new record?

    Hi,



    I have a 'Add' button to add a new record to a form. But access won't assign the PrimKey (autonumber) until some 'entries' in the form are 'modified'. But I like to open a 'subform' through a button which is linked to the 'parent form' through this ID. Is there a way to set the form 'dirty' and trigger it to refresh and set the PrimKey the minute I add a new record so I can pass it to the 'subform' by using TempVar?

    Thanks,

    DY

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    don't really understand this. to my knowledge though, records are not officially "added" when there's an autonum PK until the record is actually dirtied in another way by the user.

    I'm "almost" sure about that.

  3. #3
    dyy is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2011
    Posts
    2
    Adam,

    I don't disagree with you.

    My problem is 'how' can I 'force' access to treat the record as 'dirty' and generate the primary key? I like to do it in a macro if possible.

    To rephrase it, how I can add a record 'automatically'? I don't want to force a save though.

    Can I use 'Me.dirty' somewhere and use 'refresh' or 'refresh record' to trigger it?

    Thanks,

    AYY

  4. #4
    kennejd is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    188
    I believe if you add a me.refresh line to the button that opens your 'subform', it will save the record (if the mandatory fields are filled in) and create the primary key.

  5. #5
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by dyy View Post
    To rephrase it, how I can add a record 'automatically'?
    dump the autonumber and generate a unique number with a DLAST() or other domain function behind the ONCURRENT() event or something like that. hence, your own autonumber created via code.

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

Similar Threads

  1. Generated number do not trigger autonumber
    By Douglasrac in forum Forms
    Replies: 10
    Last Post: 03-29-2011, 08:44 AM
  2. Access DB issue with autonumber
    By cusfirstadmin in forum Forms
    Replies: 1
    Last Post: 12-02-2010, 10:45 AM
  3. date trigger
    By hyperionfall in forum Access
    Replies: 1
    Last Post: 08-08-2010, 01:15 PM
  4. Trigger subform event
    By tuna in forum Forms
    Replies: 0
    Last Post: 05-09-2010, 06:29 AM
  5. Replies: 0
    Last Post: 03-11-2010, 02: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