Re: Trouble With "For Each" and "Next"

Giganews Newsgroups
Subject: Re: Trouble With "For Each" and "Next"
Posted by:  Thelma Lubkin (thel…@alpha2.csd.uwm.edu)
Date: 29 Aug 2006

Dale <mtec…@yadtel.net> wrote:
: Access 2000

: 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")
:      ctl.SetFocus
:      DoCmd.CancelEvent
      Exit For            <================
:  End If
: Next ctl
                <snip>

    You need to exit the loop: see above.
                    --thelma
: Dale

Replies

None

In response to

Trouble With "For Each" and "Next" posted by Dale on 28 Aug 2006