Results 1 to 6 of 6
  1. #1
    crombiecrunch is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Posts
    15

    have form field randomly generate number between x - x

    hello all



    I have three form fields called Stratum_Port_One, Stratum_Port_Two and Stratum_Port_Three

    I would like to set a random value range for these three fields between say 3333 - 26000 each field can not have a duplicate number in that field and then there should be no duplicate numbers between any of the three fields.

    If that is not possible then I can just go with an autonumber starting at port_one 3333 increase by 15 for each new record port_two 4333 increase by 15 for each new record and port_three 5333 same increase by 15

    ive been searching and cant find a solution that works

  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
    53,632
    Generating custom unique identifier and saving to record requires VBA in some event. Common topic on forum. Search on those keywords should return many hits.
    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
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383

    Generate Random Number

    Doing a Random number is one thing but creating a counter is another. Here is an example that you could modify to suit your needs, Maybe?
    You could use Dmax to advance the number by whatever!


    HTH
    Attached Files Attached Files

  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
    53,632
    Relying on random generator to produce unique values would be next to impossible. Incrementing a known value by a static factor far easier. Doesn't matter if the increment is 1 or whatever, the code will simply add what it's told to. As burrina suggests, DMax is one way to code.
    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
    crombiecrunch is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Posts
    15
    thanks for the info folks, I think I got what I need working with

    =Nz(DMax("[Stratum_Port_One]", "[Table1]"), 0) + 15
    now my next question is I have 37 records in the database already, if i start with record one and the "beginning" port values, is there a way to move to each record and have it refresh with the new code? Or do i have to manually edit each record

  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
    53,632
    For only 37 records, I suggest you do it manually and get it done instead of taking time to create and debug code.
    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. How to generate a number in a form
    By Tuckerbox2081 in forum Access
    Replies: 2
    Last Post: 01-08-2014, 08:44 AM
  2. Replies: 3
    Last Post: 12-07-2013, 01:12 AM
  3. Replies: 4
    Last Post: 10-30-2012, 06:32 PM
  4. Replies: 7
    Last Post: 10-09-2012, 02:22 PM
  5. Auto generate reference number
    By JonB1 in forum Import/Export Data
    Replies: 1
    Last Post: 02-19-2011, 06:38 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