P
Pablo
Hi I have a validation on a form with the following code:
Dim Myctl As Control
For Each Myctl In Me.Controls
Select Case Myctl.ControlType
Case acComboBox, acTextBox
If IsNull(Myctl) Or Myctl = "" Then
MsgBox "Please complete all fields in this form.",
vbInformation, "Data Error:"
Myctl.SetFocus
Cancel = True
Exit Sub
End If
End Select
Next
Problem: The message box appears if I leave any field blank but as soon as I
click Okay, it will automatically close the form without me correcting the
mistake. Please help if I missed anything.
code on close button:
On Error GoTo Err_cmdClose_Click
DoCmd.Close
Exit_cmdClose_Click:
Exit Sub
Err_cmdClose_Click:
MsgBox Err.Description
Resume Exit_cmdClose_Click
Dim Myctl As Control
For Each Myctl In Me.Controls
Select Case Myctl.ControlType
Case acComboBox, acTextBox
If IsNull(Myctl) Or Myctl = "" Then
MsgBox "Please complete all fields in this form.",
vbInformation, "Data Error:"
Myctl.SetFocus
Cancel = True
Exit Sub
End If
End Select
Next
Problem: The message box appears if I leave any field blank but as soon as I
click Okay, it will automatically close the form without me correcting the
mistake. Please help if I missed anything.
code on close button:
On Error GoTo Err_cmdClose_Click
DoCmd.Close
Exit_cmdClose_Click:
Exit Sub
Err_cmdClose_Click:
MsgBox Err.Description
Resume Exit_cmdClose_Click