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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select random value from table

Status
Not open for further replies.

hayt

IS-IT--Management
Oct 5, 2004
132
US
does anyone know how i can select a random value from a field in a table (using odbc)?

i generate a recordset based on a value in a column, and now i need to randomly select a value from another column in one of the records in the recordset. any suggestions?
 
sorry, i actually built a do while loop that does a find on the recordset until not eof.

if anyone else need anything like this, here it is:

Dim sql As String
sql = "select Account_ID from ACCOUNT where Branch_ID = '" & Branch & "'"
rsaccount.open (accountsql, conn)
While (bAccount = False)
intRAccount = (1000000 * Rnd() + 1)
intRAccount = intRAccount + 10000000
Do While Not rsaccount.EOF
If rsaccount(0) = intRAccount Then
bAccount = True
End If
rsState.MoveNext
Loop
Wend


the data is a number in 10millions. i changed somethings as i am not allowed to display certain fields and values. this would be a bank database (it is similiar to what i am actually using it for).

jebenson, thanks for the quick response though, usually i wait a day or two before i hear anything back.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top