I would like to do data validation in the BeforeUpdate procedure, but Access gives me a runtime error when I try to do this:
An example of what I am trying to do is as follows:
The code breaks on Option=B. I have tried using Option.Value = B instead of Option = B, but it still gives the same error.
In plain english, what I'm trying to do is to check the value that a user supplies to a combo box, and under certain conditions, provide a message box to verify that the user has indeed made the correct selection. Based on the answer supplied by the user, the combo box should be changed to the correct value, or left as it is.
Does anyone know if this can be done?
Runtime error 2115: The Macro of function set to the BeforeUpdate or ValidationRule property for this field is preventing MS Access from saving the date in the field.
Code:
Private Sub Option_BeforeUpdate(Cancel As Integer)
If Option = A Then
Answer=MsgBox("Don't you mean B?",vbYesNo)
If Answer = vbYes Then
Cancel = True
Option = B
End If
End If
End Sub
In plain english, what I'm trying to do is to check the value that a user supplies to a combo box, and under certain conditions, provide a message box to verify that the user has indeed made the correct selection. Based on the answer supplied by the user, the combo box should be changed to the correct value, or left as it is.
Does anyone know if this can be done?
Comment