0

i'm trying to add 2 columns to the table "schede" but i always return Error 3219. Can anyone help? Here is the code:

Dim db As Database
Set db = CurrentDb()
'add columns
Dim campo1 As Field
Set campo1 = db.TableDefs("SCHEDE").CreateField("cliente", dbText, 6)
CurrentDb.TableDefs("SCHEDE").Fields.Append (campo1)
Set campo1 = CurrentDb.TableDefs("SCHEDE").CreateField("da_canc", dbText, 3)
CurrentDb.TableDefs("SCHEDE").Fields.Append (campo1)
2

1 Answer 1

0

As Fields.Append is a sub (not a function) you have to pass its arguments without parentheses (or add aCallat beginning). Also reuse your database reference (db).

Dim db As DAO.Database 'Library name to clearfy reference (e.g ADODB has a database object too)
Set db = CurrentDb()
'add columns
With db.TableDefs("SCHEDE") 'for DRY
    .Fields.Append .CreateField("cliente", dbText, 6)
    .Fields.Append .CreateField("da_canc", dbText, 3)
End With
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.