HillTJ
To train a dog, first know more than the dog..
- Local time
- Today, 07:06
- Joined
- Apr 1, 2019
- Messages
- 731
All, The 'PartyID' passed to the where statement is causing me grief. the value is not being passed, rather the text 'PartyID' is being passed. I suspect its simple syntax issue but I haven't figured it.
Appreciate some help.
Appreciate some help.
Code:
Public Function DeleteRecord(PartyID As Long)
On Error GoTo Error_Handler
Dim db As DAO.Database
Dim sSQL As String
Set db = CurrentDb
MsgBox PartyID
sSQL = "DELETE tblParty.PartyID, tblParty.DateOrigination " & vbCrLf & _
"FROM tblParty " & vbCrLf & _
"WHERE (((tblParty.PartyID)=PartyID));"
Debug.Print sSQL
db.Execute sSQL, dbFailOnError
If db.RecordsAffected = 0 Then
MsgBox "No New records were created by the above query?"
End If
Error_Handler_Exit:
On Error Resume Next
If Not db Is Nothing Then Set db = Nothing
Exit Function
Error_Handler:
MsgBox "The following error has occurred" & vbCrLf & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & _
"Error Source: cmd_AddRec_Click" & vbCrLf & _
"Error Description: " & Err.Description & _
Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _
, vbOKOnly + vbCritical, "An Error has Occurred!"
Resume Error_Handler_Exit
End Function