By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,986 Members | 2,042 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,986 IT Pros & Developers. It's quick & easy.

Fill Field With Random Integers

P: n/a
How can I fill an empty field (FieldA) in a table with random integers
between 1 and 11?

Thanks!
May 8 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Tue, 08 May 2007 23:54:40 GMT, "Steve" <so***@private.emailaddress>
wrote:

There are several ways. Off the top of my head here is one using DAO:
public sub FillWithRandom
dim rs as dao.recordset
randomize
set rs=currentdb.openrecordset("myTable", dbOpenTable)
while not rs.eof
rs.Edit
rs!FieldA = GetRandom(1,11)
rs.Update
rs.MoveNext
wend
rs.close
end sub

private function GetRandom(byval intLow as integer,byval intHigh as
integer) as integer
GetRandom=Int((intHigh - intLow + 1) * Rnd + intLow)
end function

-Tom.
>How can I fill an empty field (FieldA) in a table with random integers
between 1 and 11?

Thanks!
May 9 '07 #2

P: n/a
Thanks, Tom!
"Tom van Stiphout" <no*************@cox.netwrote in message
news:9v********************************@4ax.com...
On Tue, 08 May 2007 23:54:40 GMT, "Steve" <so***@private.emailaddress>
wrote:

There are several ways. Off the top of my head here is one using DAO:
public sub FillWithRandom
dim rs as dao.recordset
randomize
set rs=currentdb.openrecordset("myTable", dbOpenTable)
while not rs.eof
rs.Edit
rs!FieldA = GetRandom(1,11)
rs.Update
rs.MoveNext
wend
rs.close
end sub

private function GetRandom(byval intLow as integer,byval intHigh as
integer) as integer
GetRandom=Int((intHigh - intLow + 1) * Rnd + intLow)
end function

-Tom.
>>How can I fill an empty field (FieldA) in a table with random integers
between 1 and 11?

Thanks!

May 9 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.