Anchoring rectangle (1 Viewer)

Shinsen

New member
Local time
Today, 16:02
Joined
Apr 22, 2020
Messages
5
Hi,
I have rectangle placed on form and I change its (rectangles)height property through vba.
Its always anchored like default (top-left) and even if I change anchoring properties to bottom rectangle stil act as top-left anchored.

Pls help
 

Micron

AWF VIP
Local time
Today, 10:02
Joined
Oct 20, 2018
Messages
3,478
You are attempting to change the anchor property of a rectangle on an open form via vba, or you are doing it in design view and then saving the form?
 

Shinsen

New member
Local time
Today, 16:02
Joined
Apr 22, 2020
Messages
5
Thx for the reply. I want to change anchoring point of rectangle on design view.
On form view I click button which changes rectangle height but its behave always like top left anchored and I would like to have it bottom anchored. The Main vision is to create something like chart with column that i can Play with its height.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:02
Joined
May 7, 2009
Messages
19,242
anchoring is based on the Form's size not the control's size.
when the Form resize, the control follows.

maybe use subform as your container for the rectangle.
resizing the subform also resize the rectangle.
 

Shinsen

New member
Local time
Today, 16:02
Joined
Apr 22, 2020
Messages
5
Hey,
Its good tip thank you. Will give it a try.
I started to compensate rectangle movement with top property and i figured out that height and top are 1 to 1.
Cheers
 

Micron

AWF VIP
Local time
Today, 10:02
Joined
Oct 20, 2018
Messages
3,478
Post your code? If it uses inch values it might appear as you say. The value should be in twips.
 

Micron

AWF VIP
Local time
Today, 10:02
Joined
Oct 20, 2018
Messages
3,478
If the subform container idea isn't suitable, I thought of another way. Since these vba values are in Twips (assume 1" is 1440 on your pc) :
- suppose your base line is at 4320
- you want a 1" tall line (1440)
- you set your .Top value to be 4320 - 1440. This locates the top of the bar (box control).
- you set your .Height value to 1440 This stretches the bar downward 1", returning the bottom back to the base line

According to my testing, it works whether the form is at full size or not. The vertical anchor was TOP.
 

Micron

AWF VIP
Local time
Today, 10:02
Joined
Oct 20, 2018
Messages
3,478
I threw together a test form and made some pics to demonstrate the effects of various values. Last pic shows it still works when the form is resized.

bar1.jpg
.
bar2.jpg
.
bar3.jpg
 

Users who are viewing this thread

Top Bottom