i get a invalid use of null error if there is not previous note or data in the field. if there is a users note or the field is already been populated it works fine can anyone help me with this one?
Private Sub cmdUpdateNotes_Click()
On Error GoTo Err_cmdUpdateNotes_Click
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "Do you want to save your Notes?" ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "Notes" ' Define title.
Help = "" ' Define Help file.
Ctxt = 1000 ' Define topic
' context.
' Display message.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then ' User chose Yes.
MyString = "Yes" ' Perform some action.
DoCmd.SetWarnings False
DoCmd.RunSQL "Update T_Collection_Records Set T_Collection_Records.Notes = '" & _
Replace([Notes], "'", "''") & Chr(13) & Chr(10) & Date & " " & Time() & " - " & txtNotes & _
"'" & " Where T_Collection_Records.[Account #]= '" & [Account #] & "'", False
DoCmd.Close
DoCmd.SetWarnings True
Else ' User chose No.
MyString = "No" ' Perform some action.
End If
Exit_cmdUpdateNotes_Click:
Exit Sub
Err_cmdUpdateNotes_Click:
DoCmd.SetWarnings True
MsgBox Err.Description
Resume Exit_cmdUpdateNotes_Click
End Sub
Private Sub cmdUpdateNotes_Click()
On Error GoTo Err_cmdUpdateNotes_Click
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "Do you want to save your Notes?" ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "Notes" ' Define title.
Help = "" ' Define Help file.
Ctxt = 1000 ' Define topic
' context.
' Display message.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then ' User chose Yes.
MyString = "Yes" ' Perform some action.
DoCmd.SetWarnings False
DoCmd.RunSQL "Update T_Collection_Records Set T_Collection_Records.Notes = '" & _
Replace([Notes], "'", "''") & Chr(13) & Chr(10) & Date & " " & Time() & " - " & txtNotes & _
"'" & " Where T_Collection_Records.[Account #]= '" & [Account #] & "'", False
DoCmd.Close
DoCmd.SetWarnings True
Else ' User chose No.
MyString = "No" ' Perform some action.
End If
Exit_cmdUpdateNotes_Click:
Exit Sub
Err_cmdUpdateNotes_Click:
DoCmd.SetWarnings True
MsgBox Err.Description
Resume Exit_cmdUpdateNotes_Click
End Sub