Is there a "Random" command?

Soma_rich

Registered User.
Local time
Today, 14:56
Joined
May 2, 2007
Messages
58
I need to generate a random password. Is there anything in VBA I could use?
Thanks
 
there is a RANDOM statement to reset the seed used by the RANDOM function
 
hmm I have been playing with but cant seem to get it to work. Anyone know whats wrong with this code?

Randomize Forms![CyclicJobInput].Password = Int((999999 * Rnd) + 100000)
 
Here is an example from Access Help

Randomize Statement Example
This example uses the Randomize statement to initialize the random-number generator. Because the number argument has been omitted, Randomize uses the return value from the Timer function as the new seed value.

Dim MyValue
Randomize ' Initialize random-number generator.

MyValue = Int((6 * Rnd) + 1) ' Generate random value between 1 and 6.
 
OK I think I have the random bit working but I cant seem to use it to update a field???
any ideas??

Private Sub Check127_Click()
Dim randpass As Integer


Randomize randpass = Int((999999 * Rnd) + 100000)

DoCmd.RunSQL SQLText, "UPDATE JobDetails SET JobDetails.password = randpass;"



End Sub
 
the randomize statement is on a line by itself as per the example and you need to change the dim statement datatype to long.
 
DoCmd.RunSQL SQLText, "UPDATE JobDetails SET JobDetails.password = " & randpass & " WHERE SomeID_Field = xxx"
 

Users who are viewing this thread

Back
Top Bottom