I am trying to do the following code:
I am just using the textbox to mass update fields. When you delete the value out of the textbox causing a null, the sql throws a syntax error. That is what I was attempting to trap, but it isn't quite working. I believe its because strsql isn't technically null, the textbox is which is what is causing the issue (although I thought initially it would just update all fields to null).
How can I properly trap this error?
Code:
Private Sub GPTxtbx_AfterUpdate()
Dim strsql
On Err GoTo errhandler
strsql = " UPDATE tblProduct SET tblProduct.GP = " & Me.GPTxtbx & ""
strsql = strsql & " WHERE (((tblProduct.JobID)=[Forms]![JobQuote]![JobID]));"
DoCmd.SetWarnings False
DoCmd.RunSQL strsql
DoCmd.SetWarnings True
DoCmd.RefreshRecord
errhandler:
If IsNull(strsql) Then
Exit Sub
End If
End Sub
I am just using the textbox to mass update fields. When you delete the value out of the textbox causing a null, the sql throws a syntax error. That is what I was attempting to trap, but it isn't quite working. I believe its because strsql isn't technically null, the textbox is which is what is causing the issue (although I thought initially it would just update all fields to null).
How can I properly trap this error?