
Code to generate unique ID
I frequently make things more complicated than necessary. As a result of a
recent case of this I had to do the same thing that you want to do. I
created this function to return a random long integer:
Public Function RandomLong() As Long
'Returns a random long integer.
Randomize
RandomLong = Int(2 ^ 32 * Rnd - 2 ^ 31)
End Function
There is a slight chance that this will return a value that you've already
used, but I think that's an acceptable risk as there are about 4.3 billion
possible long integers. You'll need to change this a bit to use it in a
query though as it will probably give the same result in every row - look at
help for the Rnd function and it may give you clues on how to do this.
Quote:
> I am trying to build a query that generates an unique ID
> field. I keep thinking it should be easy to create a n,
> n+1 loop to generate this field but I can't seem to pull
> it off. Or am I making this more complicated than it
> needs to be. Any help would be greatly appreciated.