B
Bob Quintal
=?Utf-8?B?VHJhdXRvbg==?= <[email protected]>
wrote in
If Me.YourCheck = True Then
For Each ctl In Me.Controls
If (ctl.ControlType = acTextBox _
Or ctl.ControlType = acComboBox) _
And ctl.Tag = "Validate" Then
If Nz(ctl, "") = "" Then
MsgBox("You have to fill out" _
& " all the controls First!")
Cancel = True
Exit For
End If
End If
Next ctl
End If
Should work. Notice the indentation. See how the For each and
Next now fall at the same level of indent. I also moved the Exit
For to inside the If Nz, because that's where it wants to be.
That became understandable only when indented.
Learn to indent your code. It makes it a lot easier to debug..
wrote in
You seem to have the order of some End If and Next CTL reversed.Hi,
I have the following controls in a form: DateCompleted,
Margin1 and Margin2.
I need to set up the form so that anytime a date is populated
in the
DateCompleted control, the form will require that the controls
Margin1 and Margin2 are not null.
I found the following language in the forum that I have tried
to incorporate in the BeforeUpdate event in the form but I am
having a hard time making it work. Could someone show me how
should this language look based on my controls? I think I am
the If statement text.
Dim ctl As Object
If Me.YourCheck = True Then
For Each ctl In Me.Controls
If (ctl.ControlType = acTextBox Or ctl.ControlType =
acComboBox) And ctl.Tag = "Validate" Then
If Nz(ctl, "") = "" Then
MsgBox("You have to fill out all the controls first!")
Cancel = True
End If
Exit For
End If
End If
Next ctl
Thank you!!
Trauton
If Me.YourCheck = True Then
For Each ctl In Me.Controls
If (ctl.ControlType = acTextBox _
Or ctl.ControlType = acComboBox) _
And ctl.Tag = "Validate" Then
If Nz(ctl, "") = "" Then
MsgBox("You have to fill out" _
& " all the controls First!")
Cancel = True
Exit For
End If
End If
Next ctl
End If
Should work. Notice the indentation. See how the For each and
Next now fall at the same level of indent. I also moved the Exit
For to inside the If Nz, because that's where it wants to be.
That became understandable only when indented.
Learn to indent your code. It makes it a lot easier to debug..