Public Sub CreateRandomAutonumber()
Dim db As DAO.Database
Dim td As DAO.TableDef
Dim f As DAO.field
Set db = CurrentDb
Set td = db.CreateTableDef("Table1")
Set f = td.CreateField("MyAutoNumber")
f.Type = dbLong
f.Attributes = dbAutoIncrField
td.Fields.Append f
Set f = td.CreateField("MyTextField")
f.Type = dbText
td.Fields.Append f
db.TableDefs.Append td
td.Fields("MyAutoNumber").DefaultValue = "GenUniqueID()"
Application.RefreshDatabaseWindow
End Sub
Sunday, June 17, 2012
Membuat Random Auto Number - DAO
Labels:
Database