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!

Create a field that auto-generates.....

Status
Not open for further replies.

randusoleis

IS-IT--Management
May 11, 2001
43
US
I would like to know how to create a table that auto-generates a value.
IE: I want to create a table with a autonumber that I generate myself. Randusoleis.....
 
Try this...

Nz(DMax("FieldName", "TableName"), 0) + 1
 
Where do I place that code?
Sorry for the ignorance. Randusoleis.....
 
Try the function below. It's worked for me to create my own random key. I've never had any dupes.

Function GetGUIDRnd ()
On Error Resume Next
Dim z As String

Randomize

If Rnd(-Timer) < .5 Then
z = &quot;-&quot;
Else
z = &quot;&quot;
End If

DoEvents
DoEvents

GetGUIDRnd = z & Format(Date, &quot;ddyymm&quot;) & Int(Abs(Int(Timer * 100) + (Rnd(10000000) * 100000000)))
End Function

 
If you are using a form to input data into the table. Use the code as the default value for the control (text box, combo box, etc...) of the field you want to create the number for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top