RefEdit Exit not firing
Hi Paul,
Without seeing your code I wonder if you are getting into an eternal loop by
trying to set the focus back to the control when there is an error. Need to
disable events.
The following little test works.
Private Sub RefEdit1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Application.EnableEvents = False
On Error GoTo ReEnableEvents
If Range(Me.RefEdit1).Column 4 Then
Cancel = True 'Cancels the Exit
MsgBox "Must Select from first 4 columns"
End If
ReEnableEvents:
Application.EnableEvents = True
End Sub
During development you can comment out the following line so that you can
easily identify errors.
On Error GoTo ReEnableEvents
However, having said that, you then need the following code to re-enable
events if they get turned off and not turned back on due to an error. You can
put the code anywhere and to run just place the cursor anywhere in the sub
and press F5. (You might have already known this but it will save you from
tearing your hair out if you didn't.)
Sub Re_EnableEvents()
'Use during development to turn events on
'if code leaves them turned off.
Application.EnableEvents = True
End Sub
If your question is still not answered then perhaps you can post the
validation code you are using.
--
Regards,
OssieMac
|