我正在尝试在Access VBA中更新我的表

时间:2013-12-12 02:02:36

标签: vba ms-access access-vba

If Me.dcBox & "" = "" Then
      CurrentDb.Execute "UPDATE worklogData " & _
        " SET [Submitter] = '" & Me.subBox & "'" & _
        ", [Section] = '" & Me.secBox & "'" & _
        ", [Received By] = '" & Me.rbBox & "'" & _
        ", [Date Received] = """ & _
        ", [Serial Number] = '" & Me.snBox & "'" & _
        ", [Problem] = '" & Me.probBox & "'" & _
        ", [Computer Name] = '" & Me.cnBox & "'" & _
        ", [MAC] = '" & Me.macBox & "'" & _
        ", [Solution] = '" & Me.solBox & "'" & _
        ", [Completed By] = '" & Me.cbBox & "'" & _
        ", [Date Completed] = """ & _
        " WHERE [Order] = " & Me.orderBox.Tag & ""

    Else
        CurrentDb.Execute "UPDATE worklogData " & _
            " SET [Submitter] = '" & Me.subBox & "'" & _
            ", [Section] = '" & Me.secBox & "'" & _
            ", [Received By] = '" & Me.rbBox & "'" & _
            ", [Date Received] = #" & Me.drBox & "#" & _
            ", [Serial Number] = '" & Me.snBox & "'" & _
            ", [Problem] = '" & Me.probBox & "'" & _
            ", [Computer Name] = '" & Me.cnBox & "'" & _
            ", [MAC] = '" & Me.macBox & "'" & _
            ", [Solution] = '" & Me.solBox & "'" & _
            ", [Completed By] = '" & Me.cbBox & "'" & _
            ", [Date Completed] = #" & Me.dcBox & "#" & _
            " WHERE [Order] = " & Me.orderBox.Tag & ""
    End If

我正在尝试在Access VBA中更新我的表,但是我发现它导致运行时错误:3075'当我尝试从先前空白处更新[Date Completed]字段时,查询表达式'#'中的日期语法错误

我已将Me.probBox设置为以前为空白的某个文本值,但[问题]字段未更新。令人惊讶的是,这个没有出现错误。

1 个答案:

答案 0 :(得分:1)

试试这个

  CurrentDb.Execute "UPDATE worklogData " & _
    " SET [Submitter] = '" & Me.subBox & "'" & _
    ", [Section] = '" & Me.secBox & "'" & _
    ", [Received By] = '" & Me.rbBox & "'" & _
    ", [Date Received] = """"" & _
    ", [Serial Number] = '" & Me.snBox & "'" & _
    ", [Problem] = '" & Me.probBox & "'" & _
    ", [Computer Name] = '" & Me.cnBox & "'" & _
    ", [MAC] = '" & Me.macBox & "'" & _
    ", [Solution] = '" & Me.solBox & "'" & _
    ", [Completed By] = '" & Me.cbBox & "'" & _
    ", [Date Completed] = """"" & _
    " WHERE [Order] = " & Me.orderBox.Tag & ""