I have inherited a vba project and have been recently getting my feet wet with vba development. I have enountered an error Compile Error Object Required when running a portion of code that I have recently made edits to. Since it's a compile error, I cant see at runtime exactly which line is throwing the error. The only code I have modified is the ElseIf block in the following code... all help is appreciated.
If tableType = 1 Then 'Resident/Local
Set db = CurrentDb
db.Execute "ALTER TABLE [" & TableName & "] ALTER COLUMN [" & KeyColumn & "] COUNTER(1,1)"
ElseIf tableType = 4 Then
Set conn = New ADODB.Connection
Dim connectionString As String
Set connectionString = DLookup("[Connect]", "[MSysObjects]", "[Name] = '" & TableName & "'")
conn.connectionString = connectionString
conn.Open
Dim cmd As ABODB.Command
Set cmd = New ADODB.Command
cmd.ActiveConnection = conn
cmd.CommandText = "ALTER TABLE [" & TableName & "] ALTER COLUMN [" & KeyColumn & "] COUNTER(1,1)"
cmd.Execute
conn.Close
Else 'Linked Table
Set wsp = DBEngine.Workspaces(0)
Set db = wsp.OpenDatabase(DLookup("[Database]", "[MSysObjects]", "[Name] = '" & TableName & "'"))
db.Execute "ALTER TABLE [" & TableName & "] ALTER COLUMN [" & KeyColumn & "] COUNTER(1,1)" 'reset the autonumber column value
End If