"JackStockton" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)
> I can create a table with an autonumber field that increments with
> this code.
>
> CREATE TABLE tblTest (TestID Counter CONSTRAINT PrimaryKey PRIMARY
> KEY, Test TEXT (32))
>
>
> What I really want though is a autonumber field that uses a GUID. If
> I use the Access Table Designer, I just set the field Data Type to
> AutoNumber, then change the Field Size from Long Integer to
> Replication ID.
>
> Can this be done either via a SQL statement(s) or a VBA function? Do
> I have to do this manually with the Table Designer?
You can do it with DAO:
Sub TestReplID()
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Set db = CurrentDb
Set tdf = db.CreateTableDef("tblTest")
Set fld = tdf.CreateField("TestID", dbGUID)
fld.Attributes = fld.Attributes Or dbSystemField
tdf.Fields.Append fld
Set fld = tdf.CreateField("Test", dbText)
tdf.Fields.Append fld
db.TableDefs.Append tdf
Set fld = Nothing
Set tdf = Nothing
Set db = Nothing
End Sub
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)