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

Unique control # issue

Status
Not open for further replies.

dannyocean

Technical User
Jan 26, 2001
136
US
Hi All,

I am needing help creating a unique id # that is never repeated. The issue is that it is needed only some of the time. The number would be needed based upon the answer from another field.

If the platform field = B, I need the new unique #. All other reponses have there own unique number from our legacy reporting system.

Thanks,

Danny
 
I'm not a mathematician, but this ought to generate something random enough for you:

----------------------------------------
Public Function GenRandomNumber() As Long

Dim rnd1 As Long
Dim rnd2 As Long
Dim rnd3 As Long

rnd1 = Rnd(1024) * 1000
rnd2 = Rnd(2048) * 10000
rnd3 = Rnd(4096) * Format(Date, "#####")

GenRandomNumber = ((rnd1 * rnd2) / rnd3) + rnd2 * Format(Date, "#####")

End Function
---------------------------------------------

Me? Ambivalent? Well, yes and no....
Another free Access forum:
More Access stuff at
 
Three liner, based on the date and time:

Dim daytime As Variant
daytime = Now
UniqueIndex = Year(daytime) & Month(daytime) & Day(daytime) & CStr(CDbl(daytime))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top