I'd like to append one field property to multiple newly-created fields, like this:
Set Robo0 = RoboCallDB.CreateProperty("Format", dbText, "0")
With RoboCallDB.TableDefs(sTableName)
.Fields("Account").Properties.Append Robo0
.Fields("ServAddrPhone").Properties.Append Robo0
.Fields("CustWorkPhone").Properties.Append Robo0
.Fields("SpouseWorkPhone").Properties.Append Robo0
End With
But the code stops at after the first append and gives me Run-time error 3367. ("Cannot append. An object with that name already exists in the collection.")
I end up doing this:
RoboCallDB.TableDefs(sTableName).Fields("Account").Properties.Append & _
RoboCallDB.CreateProperty("Format", dbText, "0")
RoboCallDB.TableDefs(sTableName).Fields("ServAddrPhone").Properties.Append & _
RoboCallDB.CreateProperty("Format", dbText, "0")
RoboCallDB.TableDefs(sTableName).Fields("CustWorkPhone").Properties.Append & _
RoboCallDB.CreateProperty("Format", dbText, "0")
RoboCallDB.TableDefs(sTableName).Fields("SpouseWorkPhone").Properties.Append & _
RoboCallDB.CreateProperty("Format", dbText, "0")
Would someone be able to explain why the first snippet doesn't work, and whether there is a more elegant way than using the second snippet? Thanks in advance!