Results 1 to 6 of 6
  1. #1
    mrmims is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2013
    Posts
    53

    Auto Generate field only when needed

    Hello,



    I have an inventory database, and part of the database tracks Lot Numbers of materials purchased. Not all manufacturers supply or have Lot Numbers.

    I need a field ("Lot_Number") in a table ("TBL_Inventory") which the user either has the option to fill in with the provided manufacturer's lot number, or, if no Lot Number is provided, the user can click a button to generate a unique Lot Number for tracking purpose.

    This Lot Number IS NOT the Primary Key, "InventoryID" is.

    Any ideas?

    Thank you

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,945
    How should the generated lot number be determined? What structure should this number have? Is this a text field? Generating unique identifier is a very common topic.
    https://www.accessforums.net/program...ple-46469.html
    https://www.accessforums.net/forms/c...ble-41863.html
    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.

  3. #3
    mrmims is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2013
    Posts
    53
    Hello,

    I want the first 6 digits to be the date, Format "mmddyy", and the last 4 digits to be "0001" and incremental from there. The field will be a Text Field

    I am getting stuck on how to increment the "0001" as the other Lot Numbers in the Table will not follow the autogenerated lot number pattern.

    Thank you for the links. I will begin looking through them now for a solution hopefully!

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,945
    I recommend you not use date as component of this value. How many characters do manufacturer lot numbers use?
    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.

  5. #5
    mrmims is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2013
    Posts
    53
    Ok to not using date.

    It varies quite a lot. I have some Lot Numbers with 3 digits all numbers, and some 12 digits with numbers and letters.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,945
    Well, what I was really trying to convey is you need a consistent prefix easily recognized as yours that will help pull up the last assigned value, like:

    ABCD0001

    or

    ZZZZ0001

    or

    OurLot0001

    Only problem is that 4 number places might not be enough for the life of the db. How many would be enough? One of the links I referenced shows how I generate a unique ID in the structure:

    YYYYA-####

    The 4 number places is enough for us because the sequence starts over every year. We've never gone over 4500. You could start over every year with a structure like:

    OurLotYYYY-####
    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. Auto-Generate new records per month
    By gottnoskill in forum Programming
    Replies: 10
    Last Post: 03-12-2014, 08:16 AM
  2. Auto generate records
    By RokitRod in forum Database Design
    Replies: 1
    Last Post: 10-02-2012, 10:45 AM
  3. Auto generate reference number
    By JonB1 in forum Import/Export Data
    Replies: 1
    Last Post: 02-19-2011, 06:38 AM
  4. Auto Generate Record
    By mjhopler in forum Forms
    Replies: 2
    Last Post: 02-10-2010, 03:40 PM
  5. Replies: 1
    Last Post: 10-01-2009, 06:41 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