Function MakeUserCode OpenDB() Randomize dim getid_rs,getid set getid_rs=rsobj do while true getid="CN"&int(rnd()*(10^6)) getid_rs.open "select * from Members where User_Account='"&getid&"'",con if getid_rs.bof or getid_rs.eof then getid_rs.close exit do end if getid_rs.close loop set getid_rs=nothing MakeUserCode = getid CloseDB() End Function