i think you need to use 2 querys:
sql="select max(LICENCE_NO) as uboundval from members"
The use the rs.Fields('uboundval').Value inside your randomisations, but add the generated integer to a collection
Like
Code:
dim coll
coll = "999999999999" 'just to get a start for the collection
MaxNumber = (rs.Fields("uboundval").Value 'Highest Number from the table
Randomize 'To make sure its random
do while i <= 3
coll = coll & ", " & (Int(MaxNumber * Rnd) + 1)
i = i + 1
loop
Then your second select:
sql="SELECT LICENSE_NO,COMPANY,FNAME,LNAME,CITY,PHONE FROM members WHERE LICENSE_NO In (" & coll & ")"
The main advantage is that the recordsets that are returned from the db, will be much smaller --> for the first select, only one variale-value pair and for the second one, just 3 records with 6 values.
If you have a big table, then selecting the whole table just to get a count will generate unnescecary db-trafic.
If you do want to only use 1 select, then you best dump the table into an array (using GetRows)+ close the recordset and connection AND then use "Int(maxnumber*Rnd)" as the arraykey for the records you need.