Loop Through Detail Section Record Controls

M

Mike

Hi. I need to add an image to the detail section of a subform, and then
toggle it's Visibility based on another value in that particular record. The
loop I build to do this only seems to read the FIRST detail section record
(shown below). How can my loop read each record in the detail section?

Dim ctl As Control
For Each ctl In Me.Detail.Controls
If (ctl.Name = "imgPendingRenew") Then
ctl.Visible = RenewIsPending(Me.txtUniqueID)
End If
Next


Thanks!
 
A

Arvin Meyer MVP

Try using the recordsetclone of the subform. Your code, btw, only looks at
one record.
 
S

Stuart McCall

Mike said:
Hi. I need to add an image to the detail section of a subform, and then
toggle it's Visibility based on another value in that particular record.
The
loop I build to do this only seems to read the FIRST detail section record
(shown below). How can my loop read each record in the detail section?

Dim ctl As Control
For Each ctl In Me.Detail.Controls
If (ctl.Name = "imgPendingRenew") Then
ctl.Visible = RenewIsPending(Me.txtUniqueID)
End If
Next


Thanks!

This reference is the wrong syntax:

Me.Detail.Controls

It should be:

Me.Section(acDetail).Controls
 
M

Marshall Barton

Stuart said:
This reference is the wrong syntax:

Me.Detail.Controls

It should be:

Me.Section(acDetail).Controls


Stuart , if the detail section is named Detail (the default
name), then either syntax will work. There was a bug in
A2002 that kind of messed with some references tp an item in
a section's Controls collection, but For Each was fine.
 
S

Stuart McCall

Marshall Barton said:
Stuart , if the detail section is named Detail (the default
name), then either syntax will work. There was a bug in
A2002 that kind of messed with some references tp an item in
a section's Controls collection, but For Each was fine.

Maybe it was that bug which prompted me to always use the syntax I posted.
Can't remember.

Thanks for the clarification, Marsh.

To Mike: please just ignore my post.
 
M

Mike

Thanks all for your responses. This is a continuous form, so it doesn't
sound like this is possible.

Mike
 

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