Runtime error 2501

W

weircolin

Hi

I'm getting a runtime error when I click no when access asks me if I
want to update the records when clicking a button. The button is used
to set all the entries in a field to Null.

Can anyone help me?

Private Sub Command24_Click()
DoCmd.RunSQL "Update [Newsletter Database] Set Requirement = Null;"
End Sub
 
K

Klatuu

That is to be expected. The error description describes exactly what you
did. If you want to avoid presenting the message, add an error handler to
your sub that will ignore the error:

Private Sub Command24_Click()

On Error GoTo Command24_Click_Error
DoCmd.RunSQL "Update [Newsletter Database] Set Requirement = Null;"

Command24_Click_Exit:

Exit Sub

Command24_Click_Error:

If err <> 2501 Then
MsgBox err.Number & " " & err.Description
End If
Goto Command24_Click_Exit

End Sub
 
W

weircolin

Hi

Sorry I didn't reply sooner, first chance I've had to look at it!
Thanks so much for that, working great now.

Thanks

Colin said:
That is to be expected. The error description describes exactly what you
did. If you want to avoid presenting the message, add an error handler to
your sub that will ignore the error:

Private Sub Command24_Click()

On Error GoTo Command24_Click_Error
DoCmd.RunSQL "Update [Newsletter Database] Set Requirement = Null;"

Command24_Click_Exit:

Exit Sub

Command24_Click_Error:

If err <> 2501 Then
MsgBox err.Number & " " & err.Description
End If
Goto Command24_Click_Exit

End Sub


Hi

I'm getting a runtime error when I click no when access asks me if I
want to update the records when clicking a button. The button is used
to set all the entries in a field to Null.

Can anyone help me?

Private Sub Command24_Click()
DoCmd.RunSQL "Update [Newsletter Database] Set Requirement = Null;"
End Sub
 
Top