Suppress "Not Valid" Error message when adding text to number field

84 Views Asked by At

I'm doing the finishing touches of a MS access database, stuff revolving around input validation and error messages. I have restricted PlotSearch.value [textbox] to only accept numbers which works, but entering letters brings up a very ugly error message:

enter image description here

I was able to successfully do this with a Combobox with the following code:

Private Sub CLIENT_NotInList(NewData As String, Response As Integer)
    Response = acDataErrContinue
    MsgBox ("Error: Value is not in the list")
    CLIENT.Value = ""
End Sub

BUT ^ is a combobox and not a textbox, there is no event that can be triggered as far as I know.

I've tried:

Private Sub PlotSearch_AfterUpdate()
    DoCmd.SetWarnings False
End Sub

Private Sub PlotSearch_AfterUpdate()
    On Error Resume Next
End Sub

Private Sub PlotSearch_AfterUpdate()
    If PlotSearch.EOF Then
    MsgBox ("debug")
    Else:
    MsgBox ("works")
End Sub

The problem is that the above attempts at fixing it doesn't suppress the error message at all and Its my intention to show my own error message in there. I find it strange that ComboBoxes can have this in the form of Not in List but textboxes don't have a event that's equivalent to Not valid.

Edit: Adding a validation rule and breaking it shows this error message, which is worse than the other one. enter image description here

0

There are 0 best solutions below