Results 1 to 4 of 4
  1. #1
    turkeylord is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2014
    Posts
    3

    Update Query - Random Alphanumeric String

    Hi all! New here, hoping to learn and contribute where I can.




    The problem I'm having is that I want to generate random strings to be updated into a field in a table.

    I found a good alpha-numeric function I loaded into a module in my database. It generates a good string for me, but it puts the same string in every record, which doesn't do me any good.

    Even when I try a simpler Rnd() function, it puts the same value in every record.

    Any way around this?



    Example output:
    First Name
    Last Name
    Username
    Email
    Demo Internet
    User
    DUser1
    H6RsCjLE@[our domain].com
    Demo Internet
    User
    DUser2
    H6RsCjLE@[our domain].com
    Demo Internet
    User
    DUser3
    H6RsCjLE@[our domain].com
    Demo Internet
    User
    DUser4
    H6RsCjLE@[our domain].com



    A little background on exactly what I'm doing. A new system we're adding for our website requires a unique email address for each user - well, we have many user records whose emails are not unique in the table. The email address won't serve any functional purpose in the new system, so I was just going to load "[random]@[our domain].com".

    Thanks in advance for any input you may have!

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    You have to use the RANDOMIZE command to ensure different values.

  3. #3
    turkeylord is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2014
    Posts
    3
    Thank you for the reply! I added a Randomize statement to my function, but I still get the same value in every record. I must be doing something fundamentally wrong...

    Apologies for the MSPaint collage, lol...

  4. #4
    turkeylord is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2014
    Posts
    3
    Solved by adding a seed argument for the Rnd() function, and sending an AutoNum.



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

Similar Threads

  1. Help with RunSQL string copied from an update query
    By PlamenGo in forum Programming
    Replies: 14
    Last Post: 04-23-2014, 01:32 PM
  2. Need to use an update query on date string field
    By clawschieff in forum Queries
    Replies: 2
    Last Post: 01-28-2014, 02:07 PM
  3. Replies: 7
    Last Post: 08-26-2013, 06:05 AM
  4. alphanumeric primary key
    By slimjen in forum Database Design
    Replies: 4
    Last Post: 09-18-2011, 10:20 PM
  5. Replies: 5
    Last Post: 01-05-2010, 10:22 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