I think you just need to add End If before Next ctl.
> Hello all,
>
[quoted text clipped - 16 lines]
>
> James O
James O - 13 Nov 2006 19:37 GMT
Thanks for the reply BruceM
Ok I changed to:
Dim ctl As Control
On Error Resume Next
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
ctl.Value = True
End If
Next ctl
I unfortunately still get the same problem... it checks the first box and
then stops.
> I think you just need to add End If before Next ctl.
>
[quoted text clipped - 18 lines]
> >
> > James O
> I have a form that connect to a query, so the data on the from changes
>depending on what is selected in the query. Each record has a check box. I
[quoted text clipped - 10 lines]
>
>The problem is that it is only checking the first box and then stopping.
There should be no reason to loop through all the controls
just to locate a single check box. Just use the name of the
check box:
Me.thecheckbox = True
If you can get hold of the criteria used to select the
form's records, you should construct an Update query to
modify all the records in one operation:
strSQL = "UPDATE thetable SET theyesnofield = True " _
& "WHERE " & somethingorother
CurrentDb.Execute strSQL
If that's out of the question, then you can loop through the
form's records and set the field's (not the control's)
value:
With Me.RecordsetClone
If .RecordCount > 0 Then
.MoveFirst
Do Until .EOF
.Edit
!theyesnofield = True
.Update
.MoveNext
Loop
End If
End With

Signature
Marsh
MVP [MS Access]
James O - 13 Nov 2006 19:45 GMT
Thanks Marshall!
I went with your 3rd option which worked like a charm. Perfect I appreciate
the help very much.
> > I have a form that connect to a query, so the data on the from changes
> >depending on what is selected in the query. Each record has a check box. I
[quoted text clipped - 38 lines]
> End If
> End With