Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Query

Status
Not open for further replies.

jliz2803

IS-IT--Management
Mar 21, 2005
45
0
0
CA
Is there any way to write an update query with random values. For example I want to update records and make a certain field equal to ??1?8?5? with ?= a random value. Is this possible?
 
Have a look at the Rnd function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
You could do it with a query but since you are using random values would probably be faster just to run thru the record set.
 
What d you mean run thru the record set input all values by hand??
 
I did not say by hand
if you use rnd you will need to keep resetting the number by calling it so something like this

set rst= recordset
dim rnd1 as integer
dim rnd2 as integer
dim rnd3 as integer
dim rnd4 as integer
dim rnd5 as integer
set rst=currentdb.openrecordset("youtablename")
do until rst.eof
set rnd1 = Int((9 * Rnd) + 1)
set rnd2 = Int((9 * Rnd) + 1)
set rnd3 = Int((9 * Rnd) + 1)
set rnd4 = Int((9 * Rnd) + 1)
set rnd5 = Int((9 * Rnd) + 1)
'??1?8?5? with ?=
rst!filename = rnd1 & rnd2 & "1" & rnd3 & "8" rnd4 & "5" & rnd5
rst.movenext
loop
rst.close
set rst= nothing

 
not sure what I did here but "set rst= recordset" should be dim rst as recordset
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top