如何解决“运行时错误'3464':条件表达式中的数据类型不匹配”。在MS Access中

时间:2019-01-24 02:07:33

标签: vba ms-access

我正在处理Access上的表格。应该将数据插入表中,但我不断收到错误3464。

我对Visual Basic有点陌生。以前可以使用,但现在不再可用。我正在使用SQL Server作为后端。连接有效,它正在插入新行。我在网上看过,但没有找到关于此错误的全面解释。

Private Sub mSubmitButton_Click()

    CurrentDb.Execute "INSERT INTO dbo_Reporting_Table([Date], Vendor, Ordered_By, Picked_Up_By, Reported_By) " & _
    " VALUES('" & Me.mDate & "','" & Me.mVendor & "','" & Me.mOrdered_By & "','" & _
    Me.mPicked_Up_By & "','" & Me.mReported_By & "')"

    CurrentDb.Execute "INSERT INTO dbo_Items_Table([PO#], [Item], [Price], [Equipment], [Quantity]) " & _
    " VALUES(" & Me.mPONumber & ",'" & Me.mItemInput0 & "'," & Me.mPriceInput0 & ",'" & _
    Me.mEquipmentInput0 & "'," & Me.mQuantityInput0 & ")"


    Me.mItemInput0 = ""
    Me.mPriceInput0 = ""
    Me.mEquipmentInput0 = ""
    Me.mQuantityInput0 = ""

    Me.mDate = ""
    Me.mVendor = ""
    Me.mOrdered_By = ""
    Me.mPicked_Up_By = ""
    Me.Requery

    Exit Sub

Error_PopupMessage:
    'Response = MsgBox(Message, vbOKOnly + vbInformation, "Form Entry Hint", "help", "1000")
    Exit Sub

End Sub

任何有关我可能做错事情的建议都将不胜感激。

1 个答案:

答案 0 :(得分:0)

我的问题是,在我按提交之前,我没有在表格中输入所有必填字段。我现在有一个if语句,如果必填字段为null,则结束该过程。希望这对某人有用。

If Eval(IsNull(Me.mDate.Value) Or IsNull(Me.mVendor.Value) Or IsNull(Me.mPicked_Up_By.Value) Or IsNull(Me.mReported_By.Value)) Then
    MsgBox " Make sure you have entered the Date, Vendor, Purchaser, and signed the form. "
    Exit Sub
ElseIf Eval(IsNull(Me.mItemInput0.Value) Or IsNull(Me.mEquipmentInput0.Value) Or IsNull(Me.mPriceInput0.Value)) Then
    MsgBox " Please enter atleast one complete row of an item for the PO. "
    Exit Sub
Else
End If