Try AutoNumber. If this does not meet your needs, look at faq700-184 It is somewhat more elaborate, and illustrates how you can 'customize' the value to include additional information.
MichaelRed
redmsp@erols.com
There is never time to do it right but there is always time to do it over
Private Declare Function CoCreateGuid Lib "ole32.dll" (firstbyte As Byte) As Long
Private Declare Function StringFromGUID2 Lib "ole32.dll" (firstbyte As Byte, ByVal lpsz As Long, ByVal cbMax As Long) As Long
Private Sub Form_Load()
Dim guidbuffer(15) As Byte
Dim guidstring As String
Dim hres As Long
Dim chars As Long
"The bottom line is that almost all software ships with significant bugs and performance limitations."
Michael Spertus in Software Development Times
Actually, according to MS. GUID's are ALNOST never duplicated, while the custom generation CAN be GUARNTEED - depends on the programmer's skill, dedication ...
MichaelRed
redmsp@erols.com
There is never time to do it right but there is always time to do it over
MichaelRed,
Where did you see that MS stated that GUIDs could be duplicated (please post a link if you have one). I was under the impression that MS took the position that GUIDs would never be repeated. - Jeff Marler
Actually, I am NOT certain of where. I believe that it was in Ms. Access ver '97 Help. They also stated the 'probability' of duplication, and it was a VERY samll number - but it was NOT zero. Since Ms. (or was it me?) completly RUINED the Ms. Access Help system w/ 2K, I cannot find most of the previous help. Oh, well, so it goes.
MichaelRed
redmsp@erols.com
There is never time to do it right but there is always time to do it over
I 'tried' to get to the GUID help in MS. Access 2K. It 'threw' me into "replication Id" as fast as any 'little old lady' could possibly move. There, it says that Replication Id's are 128 Bytes. So, I guess I'm even further afield. I would THINK that 128 Bytes would be sufficient to generate a a Unique Id for every molecule and every datum in the entire known universe - on the other hand unless the Id Generator is alos universal, the possability for duplication cannot be zero.
MichaelRed
redmsp@erols.com
There is never time to do it right but there is always time to do it over
Last I heard, the GUID generation algorithm uses a few pieces of information that help to make it unique even across time and loation.
One piece that it uses is the time/date that the GUID deneration function was called. That way, if you call it again, then you will get a different number.
Another piece that it uses is the MAC address of your network card (if you have one) and/or the serial numbers of the motherboard and/or the CPU. This allows the GUID to be unique to a specific computer. Wanna test this? If you have a NIC card, then go ahead and generate a GUID (you can do this by compiling a quick VB ActiveX DLL) and look up the GUID in the registry.
{XXXXXXXX-XXXX-XXXX-XXXX-************}
The last part (last 12 digits) of the GUID is your MAC address. And, as a side note, allows people to track what computer a GUID was generated on AND, consequently, what computer compiled an ActiveX component.
That is the info that I have on the matter and that is why GUID generation does not need to be universal or talk to some global server to verify that it is unique. - Jeff Marler
Alt255 the id that was generated was
{ED8C31D8-1A30-11D5-BF4E-00508BACEE9D}
when i try to insert that into a table it gives me an error saying "quoted string not properly terminated"
Microsoft Access provides the AutoNumber data type to create fields that automatically enter a number when a record is added. Once a number is generated for a record, it can't be deleted or changed. An AutoNumber field can generate three kinds of numbers: sequential numbers that increment by one, random numbers, and Replication ID (also referred to as GUIDS — globally unique identifiers) numbers. AutoNumbers that increment by one are the most common kind of AutoNumber and are a good choice for use as a table's primary key. Random AutoNumbers will generate a random number that is unique to each record within the table. Replication ID AutoNumbers are used in database replication to generate unique identifiers for synchronizing replicas. Learn more about Replication ID AutoNumbers and when to use them.
Dim guidbuffer(15) As Byte
Dim guidstring As String
Dim hres As Long
Dim chars As Long
guidstring = String$(128, 0)
hres = CoCreateGuid(guidbuffer(0))
chars = StringFromGUID2(guidbuffer(0), StrPtr(guidstring), 128)
strUniqueID = Left$(guidstring, chars)
if i then try to insert strUniqueID into the table it says "the quoted string not properly terminated"
but if i insert the value directly it works fine
strUniqueID = "{ED8C31D8-1A30-11D5-BF4E-00508BACEE9D}"
"The bottom line is that almost all software ships with significant bugs and performance limitations."
Michael Spertus in Software Development Times
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.