Using DAO, create an Index, and set its Primary property to Yes:
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim ind As DAO.Index
'Initialize
Set db = CurrentDb()
Set tdf = db.TableDefs("MyTable")
'Create a new index. The name us usual, but not crucial.
Set ind = tdf.CreateIndex("PrimaryKey")
'Specify the field(s) in the index
With ind
.Fields.Append .CreateField("MyField")
.Primary = True 'This makes it the primary key
End With
'Add this new index to the TableDef's Indexes collection.
tdf.Indexes.Append ind
'Clean up
Set ind = Nothing
Set tdf = Nothing
Set db = Nothing