Trouble With "For Each" and "Next"

Giganews Newsgroups
Subject: Trouble With "For Each" and "Next"
Posted by:  Dale (mtec…
Date: 28 Aug 2006

Access 2000

I am trying to check the form to be sure that required fields are
entered.  For each required field (Control) I have set the tag property
to "1".  I am trying to loop through all controls with a tag property
of "1", If they are null, I want to stop the loop and setfocus on the

The below code works Except it will not stop looping when a control is
null. It will display the msgBox and then continue to the next control.

Dim ctl As Control

For Each ctl in Me,Controls
  If ctl.Tag = "1" And IsNull(ctl) Then
    MsgBox("Required Field Is Blank")
  End If
Next ctl

MsgBox("All Required Fields Complete")

Seems simple, but I can't get the loop to stop at the CancelEvent.

Any and ALL help truely appreciated!