我想用同一表中其他列的连接来完成该列,但出现错误。我的代码如下:
Dim tbl2 As DAO.TableDef
Dim db2 As DAO.Database
Dim fld2 As DAO.Field
Set db2 = CurrentDb
Set tbl2 = db2.TableDefs("Table")
With tbl2
Set fld2 = tbl2.CreateField("Concatenate", dbText)
.Fields.Append fld2
'*and below is the part when I get errors on both options:*
fld2.Expression = "Account" & "-" & "Name" '<-- I get an error "Method or data member not found
fld2.Attributes = "Account" & "-" & "Name" '<-- when I change to this I get an error "Type mismatch"
End With
Set fld2 = Nothing
Set tbl2 = Nothing
Set db2 = Nothing
实际上,代码可以正常工作,字段可以作为文本正确创建,但是它不希望使用值来完成。
您能帮忙吗?如何更改代码?这两个选项都是错误的!
答案 0 :(得分:0)
我认为应该是:
fld2.Expression = "[Account]-[Name]"