Results 1 to 8 of 8
  1. #1
    Makis is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    May 2014
    Posts
    1

    Question Random Pin Numers

    Hello all.



    First of all I want to say that my experiense in Access is very little.
    I want to create a database with

    Random generated numbers that starts with 3 specific digits and continues with 7 or more random digits.
    Exampe 309.1234567

    Every number must be unique (only the second part - the 7 digits one).
    Also, I must have a report anout these numbers. I may have 5 different groups (one starting with 309 the second 310 thrird 311 etc) and a function that I can check where a specific pin is located (in which group) and mark it as used or not.

    Is this possible?

    Thank you in advanced.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by Makis View Post
    ...
    Is this possible?
    Sure. You should probably start with mastering the random function. Here is an example.
    Code:
    Dim intMyRandom As Integer
    Dim intOriginalNum As Integer
    
    intOriginalNum = 9
            Randomize
            intMyRandom = (intOriginalNum * Rnd) + 1
            MsgBox intMyRandom
    You should probably generate a random for each of the 7 digits and then concatenate as a string. You could then compare to an existing recordset using something like DAO to ensure non-duplicating numbers.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    Build a keyed table so you dont get duplicates..then run a query to append the function RND(7)
    to get your randoms.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by ranman256 View Post
    ... the function RND(7)...
    What does that do? Is that parameter to provide a 7 digit result?

  5. #5
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    It builds the 7 digits of un-duplicated pins.

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by ranman256 View Post
    It builds the 7 digits of un-duplicated pins.
    Interesting. I am not seeing how to consistently return 7 digits. Perhaps you can show an example.

  7. #7
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    INSERT INTO tPINs ( Num ) SELECT Rnd(7) AS Expr1;

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by ranman256 View Post
    INSERT INTO tPINs ( Num ) SELECT Rnd(7) AS Expr1;
    I do not see that as a solution considering the business rule of 7 or more digits.

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

Similar Threads

  1. Random Query
    By TrackStar in forum Queries
    Replies: 0
    Last Post: 06-20-2012, 09:10 AM
  2. Random value generation?
    By Delta223 in forum Access
    Replies: 4
    Last Post: 01-12-2012, 12:14 PM
  3. No-So-Random Number
    By oleBucky in forum Programming
    Replies: 8
    Last Post: 11-08-2011, 11:02 AM
  4. Random ID Field
    By avarusbrightfyre in forum Access
    Replies: 3
    Last Post: 10-17-2011, 11:52 AM
  5. Random 0 now
    By Mounds in forum Access
    Replies: 4
    Last Post: 04-29-2011, 10:04 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