Results 1 to 3 of 3
  1. #1
    Richie27 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Location
    Ireland
    Posts
    159

    Insert a unique and autoincrementing value from an unbound form

    Hi all,

    I have a table called actions with various fields like pkFileAction,actionDesc, actionDate, actionReason, actionInstance etc.

    There are times when I will want to input multiple values, as many as ten, into this table from an unbound form.

    In the actionInstance field I want to record a number which uniquely identifies that input instance.

    The first instance of say, ten files being recorded will have an actionInstance value of 1 and the next instance of say one file will be recorded as 2 and then 3 and so on..........

    I need to be able to uniquely identify each instance of records being inserted as a unique event. The autoincrement pk field won't work as it stores an id for each of the files - and I want to record the same number for things that happen at the same time.

    Hope that is clear.



    Rich.

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    I think what you can do is use a DMax() function to get the previous highest number from the actionInstance field & increment it by one.
    Eg:
    Code:
    NewactionInstance = DMax("actionInstance", "YourTableName") + 1
    Where NewactionInstance is a numeric variable to hold the new actionInstance for the current number of entries.
    Then - use NewactionInstance for every new record you enter.

    Each time you enter an instance, you will get a number one up from the highest action instance number in there.

    Does that help?
    Last edited by Robeen; 05-18-2012 at 08:33 AM.

  3. #3
    Richie27 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Location
    Ireland
    Posts
    159
    Ya, thank you.

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

Similar Threads

  1. Unique queries - Unique Count
    By bigfish in forum Queries
    Replies: 7
    Last Post: 03-14-2012, 01:28 PM
  2. Unbound Form
    By tia in forum Forms
    Replies: 2
    Last Post: 02-09-2012, 07:22 AM
  3. Replies: 4
    Last Post: 04-22-2011, 03:08 PM
  4. Unbound form example
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 08-24-2010, 12:25 AM
  5. Replies: 0
    Last Post: 05-09-2010, 08:43 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