【问题标题】:How to fill a column with data in access table via macro如何通过宏用访问表中的数据填充列
【发布时间】:2018-11-21 10:11:47
【问题描述】:

我想用来自同一个表中的其他列的连接来完成该列,但我得到了错误。我的代码如下:

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

实际上代码有效,字段被正确创建为文本,但它不想用值完成。

你能帮忙吗?如何更改代码?两个选项都错了!

【问题讨论】:

    标签: ms-access dao create-table


    【解决方案1】:

    我认为应该是:

    fld2.Expression = "[Account]-[Name]" 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-29
      • 2016-01-21
      • 2019-02-19
      • 2019-06-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多