Reputation: 430
I am working on a form on Access. It is supposed to insert data into a table, but I keep getting error 3464.
I am a little new to Visual Basic. This was previously working, but no longer. I am using SQL Server as a back-end. The connection works and it was inserting new rows. I have looked online but have not found a comprehensive explanation of this error.
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
Any advice on what I might be doing wrong would be greatly appreciated.
Upvotes: 1
Views: 8814
Reputation: 430
My problem was that, in the form, I was not entering all of the required fields before I pressed submit. I now have an if statement that ends the process if the required fields are null. Hope this might be of use to someone.
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
Upvotes: 2