For...Each - can it apply to form section controls?

AnnusHorribilis

Registered User.
Local time
Today, 02:48
Joined
Apr 12, 2005
Messages
13
I want to loop through labels on a form header to check if they are visible, but my syntax isn't working.

I am using:

For each ctl in Me.Form header
If ctl.controltype = acLabel Then......

....Next ctl


But I get an error message: Doesn't support this property or method.

Is there another way just to loop thro' the header?
 
Thanks Roy, I learn something new every day but this one could be useful.

For Each ctl In Me.Section(acHeader).Controls

Normally what I would have done is waste a Tag property trying to separate the header controls from the rest.

Nice not to have to waste resources.

Thanks again and regards,
Chris.
 
Thank you for the kind words, ChrisO, and your very polite way of correcting the syntax (...forgetting the collection...)

And yes, it can be very usefull, for instance when trying to address controls on a specific page on a tab control

me!mytab.pages("mypage").controls

(I remember first time I was attempting to address controls on a tab page, checking if ctl.parent.name = "name of tab page", which of course provided some amusing hours of debugging, because the parent control of attached labels, are the control it's attached to...)
 
You’re very welcome Roy because politeness is not one of my stronger points. :o
(I was just so happy to learn something today that I got all misty eyed. ;) )

Thanks again and I will tuck that one away for latter use. :D

Regards,
Chris.
 
thanks, both!

you can abuse me horribly, as long as you come up with the answers! :)
 
Annus, I would not abuse you horribly, believe you me that was the furthest thing from my mind.

Roy and I did come up with the answer.

All you need is to read…and understand (which admittedly at times can be difficult)

The answer is there…and that is it.

Look again at Roy’s answer.

Also look again at your post entitled “Change Color of active control”.
 
Chriso

You must have misunderstood me... I was thanking you both for finding the solution, which I tried and which worked. I always do a search before asking questions, but on this occasion had no luck. I also trawled through an Access manual without luck. So your intervention was a godsend.


I apologize if my flippant answer gave you the idea that I was being churlish. I assure you I am most grateful for this and the help with the Backcolor Property.
 
You are correct Annus, I did misread your reply (in particular the heading) and I apologize for that. :o

Glad it’s all working correctly for you and again sorry for not taking the time to read your response correctly.

Have a good day and regards,
Chris.
 
And the award for Most Polite Thread goes to.... :p
 
ChrisO said:
Annus, I would not abuse you horribly

Annus, if ChrisO won't, I believe I can be of some service. Tell me, how might I hurt you?
 

Users who are viewing this thread

Back
Top Bottom