在字段名称中使用变量-SQL Update语句

用户名

我是使用Access 2010的新手。我希望执行以下sql update语句,但是语法有问题。该表称为“预测”,用户将编辑和更新预测的数量。

问题-表的字段名称是2014_1、2014_2、2014_3 ...,表示存储在数组中的不同月份。我已经做了一些研究,我相信动态地做到这一点的方法是:

Dim sqlString As String
    sqlString = "UPDATE Forecasts " & _
    " SET Branch_Plant=" & Me.txtBranch_Plant & _
    ", Item_Number_Short='" & Me.txtItem_Number_Short & "'" & _
    ", Description='" & Me.txtDescription & "'" & _
    ", UOM='" & Me.txtUOM & "'" & _
    ", Estimated_Cost=" & Me.txtEstimated_Cost & _
    ", Requesting_Business_Unit='" & Me.txtRequesting_Business_Unit & "'" & _
    ", End_Customer='" & Me.txtEnd_Customer & "'" & _
    ", Project='" & Me.txtProject & "'" & _
    ", Forecasts." & "[" & arrMonthToDisplay(0) & "]" = " & Me.txtProjectedJanVolume " & _
    " WHERE ID =" & Me.txtID.Tag

    MsgBox ("This is the output: " & sqlString)
    CurrentDb.Execute sqlString 

在添加此行之前,一切正常

Forecasts." & "[" & arrMonthToDisplay(0) & "]" = " & Me.txtProjectedJanVolume

msgbx输出现在显示:“ False”。sqlString有什么问题?

请帮忙!非常感谢你。

沙赫卡佩什
", Forecasts.[" & arrMonthToDisplay(0) & "] = " & Me.txtProjectedJanVolume & _
" WHERE ID =" & Me.txtID.Tag

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章