arage
02-01-2001, 09:48 AM
Hi,
I’m trying to put code in my form close event that’ll check for specific errors. Problem is I don’t know how to keep the close event from happening once I’ve determined a control has an error. I would like to bypass the close event in an effor to allow the person to correct the error. Could someone point out how to do that?
Here’s a part of my form close event, that while, displaying the message, immediately closes the form once it has run. The reason I’m putting the form control code in the close event is that there are so many different events and controls & someone may be using a mouse or a keyboard to enter/navigate data, that it seems madness to code each event for each control that may need to have some checking done on it, I therefore thought my best bet would be to code in the close event and determining all my errors in there, display a message, leave the close event and allow the correction to be made.
Private Sub Form_Close()
'check to see if payment type is blank
If IsNull(Me.cmbType) Then
MsgBox "Payment type required.", vbExclamation, "Error"
CtrlName = Me.cmbType.Name
Me.Controls(CtrlName).SetFocus
Exit Sub
End If
Endsub
I’m trying to put code in my form close event that’ll check for specific errors. Problem is I don’t know how to keep the close event from happening once I’ve determined a control has an error. I would like to bypass the close event in an effor to allow the person to correct the error. Could someone point out how to do that?
Here’s a part of my form close event, that while, displaying the message, immediately closes the form once it has run. The reason I’m putting the form control code in the close event is that there are so many different events and controls & someone may be using a mouse or a keyboard to enter/navigate data, that it seems madness to code each event for each control that may need to have some checking done on it, I therefore thought my best bet would be to code in the close event and determining all my errors in there, display a message, leave the close event and allow the correction to be made.
Private Sub Form_Close()
'check to see if payment type is blank
If IsNull(Me.cmbType) Then
MsgBox "Payment type required.", vbExclamation, "Error"
CtrlName = Me.cmbType.Name
Me.Controls(CtrlName).SetFocus
Exit Sub
End If
Endsub