Results 1 to 2 of 2
  1. #1
    jlreis28 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    4

    Populate a text field with information from the previous record incremented by 1

    Good day.

    I am trying to automate ID number generation. I created a table with the field "DeviceID" and gave it a default value of 100000000. When the first record is saved, I want to make the next record in the form start with the previous record's DeviceID value, incremented by 1.

    Is there an easy way to code this into the GotFocus event? That seems to be the easiest way to may the procedure kick off. I am not worried about gaps in the numbering as I want the DeviceID field to be unique. And if there is an easier/better way (without using autonumber), I am certainly game.



    Thanks,
    Justin

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    One way may be is in the BeforeUpdate event of the DeviceID control to set the DefaultValue property:

    Me.DeviceID.DefaultValue = Me.DeviceID + 1
    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.

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

Similar Threads

  1. Replies: 1
    Last Post: 09-07-2011, 09:22 AM
  2. Replies: 1
    Last Post: 04-21-2011, 11:27 AM
  3. Populate field from field on previous record
    By randolphoralph in forum Forms
    Replies: 7
    Last Post: 03-04-2011, 11:28 AM
  4. Replies: 2
    Last Post: 05-05-2010, 02:52 PM
  5. Populate date from previous record
    By Lianes in forum Access
    Replies: 3
    Last Post: 09-19-2009, 03:42 PM

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