Delete record if Null

Ripsnorta

New member
Local time
Today, 12:56
Joined
Feb 6, 2006
Messages
5
I'm hoping someone can help a noob with a simple problem:) I did a search but couldn't find the answer.

When a user clears a record and leaves it Null I would like to prompt them whether they would like to delete the record before the access error message about invalid use of Null comes up. If they don't want to delete the record then the code should undo the change. The problem I have is I can't seem to run my code without the access error coming up. I can't see where I can trap the error (err.Number 3398).

For example, this doesn't work:
Code:
Private Sub txtSalesItem_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_txtSalesItem_BeforeUpdate

Dim response as Integer

If IsNull(Me.txtSalesItem) Then
   response = MsgBox("Do you want to delete this category?", vbExclamation + vbYesNo, "Delete Sales Item?")

   If response = 6 Then
      Runcommand acCmdDelete
   
   else
      RunCommand acCmdUndo
   endif

End If
.
.
.

I know I can put in a validation rule, but I would like to go a bit further.
Does anyone have any suggestions?
 
Hello Ripnorta!

Look at "DemoFormErrorA2000.mdb",
You have got a two possibilitis, I think it can help you.
 

Attachments

MStef said:
Look at "DemoFormErrorA2000.mdb",
You have got a two possibilitis, I think it can help you.


Thanks MStef

Both those options do what I was looking for. I think my main problem was I was omitting to setwarnings = false to avoid the error message.
 

Users who are viewing this thread

Back
Top Bottom