Solved Loop through all buttons in a form

freuzo

Member
Local time
Today, 12:43
Joined
Apr 14, 2020
Messages
98
Hi,
I have a form with many buttons. I need the labels of those buttons to be align on the left so I have this code on the load event :

Code:
btn_1.Alignment = 1
btn_2.Alignment = 1
btn_3.Alignment = 1

and so on...

How can I loop through those buttons to set this one time and for all. I don't want to come back to add a line everytime that I'll have to add a control in that form.

Thanks in advance.
 
Something like?
Code:
For x = 1 To 3
    Me.Controls("btn_" & x).Alignment = 1
Next
 
Why are you doing this every time the form opens? Why would you not just fix the layout and be done with it?
 
Why are you doing this every time the form opens? Why would you not just fix the layout and be done with it?
I'm building in ms access 2013 and there is no way to align button's labels in the design mode (or did I miss someting ? :unsure:).
So I searched and found this code.
 
Not sure what your problem is but I do this all the time when I create forms. Please post pictures or the form itself.
 
Not sure what your problem is but I do this all the time when I create forms. Please post pictures or the form itself.


Capture d’écran 2021-12-06 202357.png


I'm Trying to have all labels align on the left.
If there is a way in the design mode in access 2013 to do that, I didn't see it. So I found the code above (made on the first two buttons as you see).
 
View attachment 96591

I'm Trying to have all labels align on the left.
If there is a way in the design mode in access 2013 to do that, I didn't see it. So I found the code above (made on the first two buttons as you see).
Look for the Alignment property.

1638821334181.png
 
presume you know you can select all the (relevant) controls and all common properties will show so you can set the alignment for all controls in one click
 

Users who are viewing this thread

Back
Top Bottom