complie error:next without for

W

Walter

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
 
B

Beetle

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
 
S

Stuart McCall

Walter said:
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

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top