Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Dec 2003
    Location
    UK
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Access, vb and rnd

    I am trying to get a random number as my key, but always a positive and always 6 digits (and obveously no duplicates).

    I have read on forums that this can be done with visual basic - I have the script and I can open the vb editor in access - but thats me stuck!!

    WHERE do i write the script in vb editor, and HOW do i then use this script in my access table?

    Could someone hold my hand (virtually that is, no funny emails please!) and walk me through.

    Cheers

    Monkey
    Monkey

    My head hurts!

  • #2
    Regular Coder
    Join Date
    Apr 2003
    Location
    Canada, Ontario, Mississauga
    Posts
    312
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Are you trying to find out how to generate a random number or where to endit the code?

    to generate a randome number from 0 to 6
    Int(Rnd * 7)
    reason I multiply by 7 because the number always lower than 7, what number is lower than 7? it's 0 to 6

    to edit code in access using Visual Basic
    Open Access
    Click Tools on the menu bar,
    then select Macro,
    then click Visual Basic Editor.

    Mike

  • #3
    Regular Coder
    Join Date
    Dec 2003
    Location
    UK
    Posts
    106
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I can open the vb editor
    WHERE do i write the script in vb editor, and HOW do i then use this script in my access table?
    I can generate a random number (as in, write the script) but dont know WHERE to put it IN vbeditor (never used it before) and how to use that code as my random number key in my table.

    cheers
    Monkey

    My head hurts!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •