Good morning,
I have a question....
I'm sure some may recognize to following code, I altered it a bit and it works great but when I click a button called "Search Students", which is a dialog, popup and modal search form to select another record, that form opens with the validation message. Is there away to cancel the underlying action to prevent the Search form from opening?
I put it in the Form_BeforeUpdate event
Dim Msg As String, Style As Integer, Title As String
Dim DL As String, ctl As Control, strControl As String
Set ctl = Screen.ActiveControl
strControl = ctl.Tag
DL = vbNewLine & vbNewLine
For Each ctl In Me.Controls
If Not IsNull(ctl.Tag) Then
If Trim(ctl & "") = "" Then
Msg = ctl.Tag & " is a Required Field!" & DL & _
"Correct this field in order to continue . . ."
Style = vbCritical + vbOKOnly
Title = "Required Data Error"
MsgBox Msg, Style, Title
ctl.SetFocus
Cancel = True
Exit For
End If
End If
Next
Thanks
I have a question....
I'm sure some may recognize to following code, I altered it a bit and it works great but when I click a button called "Search Students", which is a dialog, popup and modal search form to select another record, that form opens with the validation message. Is there away to cancel the underlying action to prevent the Search form from opening?
I put it in the Form_BeforeUpdate event
Dim Msg As String, Style As Integer, Title As String
Dim DL As String, ctl As Control, strControl As String
Set ctl = Screen.ActiveControl
strControl = ctl.Tag
DL = vbNewLine & vbNewLine
For Each ctl In Me.Controls
If Not IsNull(ctl.Tag) Then
If Trim(ctl & "") = "" Then
Msg = ctl.Tag & " is a Required Field!" & DL & _
"Correct this field in order to continue . . ."
Style = vbCritical + vbOKOnly
Title = "Required Data Error"
MsgBox Msg, Style, Title
ctl.SetFocus
Cancel = True
Exit For
End If
End If
Next
Thanks