Try the VBA below.
Sub AddPrimaryX()
Dim dbs As Database
Dim tdf As TableDef
Dim idx As Index
Set dbs = CurrentDb
Set tdf = dbs.TableDefs("YourTableHere")
With tdf
Set idx = .CreateIndex("YourTargetFieldNameHere")
idx.Fields.Append idx.CreateField("YourTargetFieldNameHere")
idx.Primary = True
.Indexes.Append idx
End With
dbs.Close
End Sub