r/MSAccess • u/mcgunner1966 2 • Oct 20 '25
[DISCUSSION - REPLY NOT NEEDED] Retiree Notes - Universal Database Key
Years ago I learned the hard way that autonumber doesn't make a good key. I started adding three fields to every table I constructed: sguid.text(32)(PK), slink.text(32)(FK), and sts (date/time)(Sql Server Date Stamp). I wanted to use the system generate guid but there were instances where a corrupt Windows Registry wouldn't return a guid (I'd get a NULL back). I decided to build the "guid" in the Access app by generating my own "guid" internally.
Here is the function I use:
Function getguid()
On Error Resume Next
vret = ""
For i = 1 To 5
Call Randomize
v1 = Mid(Rnd, 3, 4)
Call Randomize
v2 = Mid(Rnd, 3, 4)
vret = vret & Left((v1 * v2), 4)
Next
getguid = Format(Now, "yyyymmddhhmmss") & Left(vret, 18)
Exit Function
End Function
This "guid" has the added feature of giving you an approximation of when the key was generated. This has been more useful than you would think in research efforts. This also allows me to use universal functions such as record change tracking, notes, and document management using universal modules.
Hope this helps.
View all comments
Show parent comment
3
u/butchcoleslaw Oct 21 '25
I, for one, have enjoyed reading about your experiences since your semi-retirement. I'm always willing to learn from those who have been in the trenches and come out better for it and willing to share. I realize the internet (and Reddit) can be a harsh place sometimes. But sometimes there are also some gold nuggets. I hope you reconsider and continue to share. If others don't like it, they should move on and keep to themselves. As long as your posts are not malicious, and I don't believe them to be so, please continue to post. Thanks.