Hi,
I have a form Delete which contains four fields i.e. Date, City, Depots and Vendor, which has combobox.
I am trying to delete a record from table "Sheet1" based on the combobox, for which i have written the following code, but getting an error at the lines highlighted in red :
Private Sub Command30_Click()
On Error GoTo Err_delete_Click
Dim stDocName As String
Dim intResponse As Integer
intResponse = MsgBox("Are you sure you want to delete this record?", vbYesNo + vbExclamation, "Cash Management Team")
Select Case intResponse
Case vbYes
CurrentDb.Execute _
"DELETE FROM SHEET1 " & _
"WHERE DATE = #" & Me.Start & "'" and _
CITY = '" & Me.citycombo & "'" and _
Depots = '" & Me.depotscombo & "'" and _
Vendor = '" & me.vendorcombo & "'"
MsgBox "The Selected record will be deleted", vbOKOnly + vbInformation, "Cash Management Team"
Case Else
MsgBox "Record not deleted.", vbOKOnly + vbInformation, "Cash Management Team"
End Select
Exit_delete_Click:
Exit Sub
Err_delete_Click:
DoCmd.SetWarnings True
MsgBox Err.Description
Resume Exit_delete_Click
End Sub
Can anybody help me.
Thanks
I have a form Delete which contains four fields i.e. Date, City, Depots and Vendor, which has combobox.
I am trying to delete a record from table "Sheet1" based on the combobox, for which i have written the following code, but getting an error at the lines highlighted in red :
Private Sub Command30_Click()
On Error GoTo Err_delete_Click
Dim stDocName As String
Dim intResponse As Integer
intResponse = MsgBox("Are you sure you want to delete this record?", vbYesNo + vbExclamation, "Cash Management Team")
Select Case intResponse
Case vbYes
CurrentDb.Execute _
"DELETE FROM SHEET1 " & _
"WHERE DATE = #" & Me.Start & "'" and _
CITY = '" & Me.citycombo & "'" and _
Depots = '" & Me.depotscombo & "'" and _
Vendor = '" & me.vendorcombo & "'"
MsgBox "The Selected record will be deleted", vbOKOnly + vbInformation, "Cash Management Team"
Case Else
MsgBox "Record not deleted.", vbOKOnly + vbInformation, "Cash Management Team"
End Select
Exit_delete_Click:
Exit Sub
Err_delete_Click:
DoCmd.SetWarnings True
MsgBox Err.Description
Resume Exit_delete_Click
End Sub
Can anybody help me.
Thanks