Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: complie error:next without for

Geek News

complie error:next without for
Walter 12/11/2008 6:04:23 PM
The following code gives me the next without for error. What is wrong?

Dim c As Control

If Not Me.NewRecord Then
For Each c In Me.Controls
If c.Tag = "Vehicle" Or c.Tag = "Outsourced" Then
If IsNull(c) Then
c.Visible = False
Else
c.Visible = True
End If

Next c
--
Thanks for your help!
Walter
RE: complie error:next without for
Beetle 12/11/2008 6:44:14 PM
You're getting that error because you are missing an End If inside the
For...Next loop. You're also missing a closing End If (at least in the
example you posted). Corrected code below;

Dim c As Control

If Not Me.NewRecord Then
For Each c In Me.Controls
If c.Tag = "Vehicle" Or c.Tag = "Outsourced" Then
If IsNull(c) Then
c.Visible = False
Else
c.Visible = True
End If
End If

Next c
End If


--
_________

Sean Bailey


"Walter" wrote:

[Quoted Text]
> The following code gives me the next without for error. What is wrong?
>
> Dim c As Control
>
> If Not Me.NewRecord Then
> For Each c In Me.Controls
> If c.Tag = "Vehicle" Or c.Tag = "Outsourced" Then
> If IsNull(c) Then
> c.Visible = False
> Else
> c.Visible = True
> End If
>
> Next c
> --
> Thanks for your help!
> Walter
RE: complie error:next without for
Walter 12/11/2008 7:04:00 PM
Thanks for catching that. I wasn't looking at the if statements.
--
Thanks for your help!
Walter


"Beetle" wrote:

[Quoted Text]
> You're getting that error because you are missing an End If inside the
> For...Next loop. You're also missing a closing End If (at least in the
> example you posted). Corrected code below;
>
> Dim c As Control
>
> If Not Me.NewRecord Then
> For Each c In Me.Controls
> If c.Tag = "Vehicle" Or c.Tag = "Outsourced" Then
> If IsNull(c) Then
> c.Visible = False
> Else
> c.Visible = True
> End If
> End If
>
> Next c
> End If
>
>
> --
> _________
>
> Sean Bailey
>
>
> "Walter" wrote:
>
> > The following code gives me the next without for error. What is wrong?
> >
> > Dim c As Control
> >
> > If Not Me.NewRecord Then
> > For Each c In Me.Controls
> > If c.Tag = "Vehicle" Or c.Tag = "Outsourced" Then
> > If IsNull(c) Then
> > c.Visible = False
> > Else
> > c.Visible = True
> > End If
> >
> > Next c
> > --
> > Thanks for your help!
> > Walter
Re: complie error:next without for
"Stuart McCall" <smccall[ at ]myunrealbox.com> 12/11/2008 7:36:37 PM
"Walter" <Walter[ at ]discussions.microsoft.com> wrote in message
news:588C807D-4DAC-4557-BF7A-CD7D0B09DFDE[ at ]microsoft.com...
[Quoted Text]
> The following code gives me the next without for error. What is wrong?
>
> Dim c As Control
>
> If Not Me.NewRecord Then
> For Each c In Me.Controls
> If c.Tag = "Vehicle" Or c.Tag = "Outsourced" Then
> If IsNull(c) Then
> c.Visible = False
> Else
> c.Visible = True
> End If
>
> Next c
> --
> Thanks for your help!
> Walter

You're missing an End If, following c.Visible = True


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net