I need to ADD a FIELD to a table using ALTER TABLE ADD COLUMN. I need to use a variable for the Field Name (COLUMN).
I have code that checks if a FIELD exists (this works). If the FIELD does NOT exist I need to create it. My code has assigned a name to a variable (sFieldName).
I assign "Task10Assigned" to sFieldName (this name changes often). I searched my table and find that this field name does NOT exist so I try to create the FIELD using:
Dim sFieldName as String
myDB.Execute ('ALTER TABLE tblHardwareInfoMerged ADD COLUMN ['" & sFieldName & "'] TEXT(25)') but it says OBJECT REQUIRED.
IF I hard code a column name instead of the variable it works!!
myDB.Execute ("ALTER TABLE tblHardwareInfoMerged ADD COLUMN [Task10Assigned] TEXT(25)")
What am I doing wrong?