Ok, here is my code:
I am trying to delete the supplier from a table called "Suppliers" where the Supplier Name and Code are the same as the text boxes txtSupplierName and txtSupplierCode respectively. I had to make the text box values null, otherwise the supplier was not actually deleted for some reason. The above code now works, but I now get a new "supplier" with blank Supplier Name and Supplier Code fields. Does anyone have any advice on how to stop this from happening please?
Code:
Private Sub cmdRemove_Click()
On Error GoTo Err_cmdRemove_Click
Dim SQL As String
Dim stLinkCriteria As String
SQL = "DELETE * FROM Suppliers WHERE ((Suppliers.[Supplier Name])= '" & txtSupplierName & "') AND (Suppliers.[Supplier Code]='" & txtSupplierCode & "' );"
CurrentProject.Connection.Execute SQL
txtSupplierName = Null
txtSupplierCode = Null
Exit_cmdRemove_Click:
Exit Sub
Err_cmdRemove_Click:
MsgBox Err.Description
Resume Exit_cmdRemove_Click
End Sub
I am trying to delete the supplier from a table called "Suppliers" where the Supplier Name and Code are the same as the text boxes txtSupplierName and txtSupplierCode respectively. I had to make the text box values null, otherwise the supplier was not actually deleted for some reason. The above code now works, but I now get a new "supplier" with blank Supplier Name and Supplier Code fields. Does anyone have any advice on how to stop this from happening please?