Create a Visual Basic for Applications procedure in the
Access project that runs the
ADO Command object. The
ADO Command object can programmatically make changes to the design of a large
table without error if the
.CommandTimeOut property is set either to a large enough positive value or to
zero (0), which means that is should never time out.
In the
following example, the field BigID is added and is also set as the primary key
in the table tblLarge:
Sub addPrimaryKey()
Dim ADOCmd As ADODB.Command
Set ADOCmd = New ADODB.Command
With ADOCmd
.CommandText = "ALTER TABLE tblLarge ADD " _
& "BigID INT IDENTITY " _
& "CONSTRAINT BigID_pk PRIMARY KEY;"
.ActiveConnection = CurrentProject.Connection
.CommandTimeout = 0
.Execute
End With
Set ADOCmd = Nothing
End Sub