How to move control within a form using VBA

G

Guest

Based on conditions when opening a form, I'm hiding certain controls and
attempting to move vertically a group of controls that includes list boxes,
text boxes, labels, etc.

I configured a "prototype" form with the controls in their modified location
to determine the value of the "Top" property of each control, then created a
procedure to relocate all the applicable controls as the form is opened,
using statements such as:

Me!LocSelectedBox.Top = 2.375

However, the form does not display the controls in the expected location,
but rather they are overlapping other controls higher in the form.

I will appreciate anyone's correction of my approach to trying to relocate
the controls?
 
R

Rick Brandt

Richard said:
Based on conditions when opening a form, I'm hiding certain controls
and attempting to move vertically a group of controls that includes
list boxes, text boxes, labels, etc.

I configured a "prototype" form with the controls in their modified
location to determine the value of the "Top" property of each
control, then created a procedure to relocate all the applicable
controls as the form is opened, using statements such as:

Me!LocSelectedBox.Top = 2.375

However, the form does not display the controls in the expected
location, but rather they are overlapping other controls higher in
the form.

I will appreciate anyone's correction of my approach to trying to
relocate the controls?

In code Top and Left are always in twips, not inches. Switch to those (1440
per inch) and your code will work as expected.
 
G

Guest

The Top property is a long data type expressed in twips. There are 1440
twips per inch. Therefore, if you are wanting 2.375, set it to 3420
 
G

Guest

Dave & Rick,

Thank you both for the almost immediate response to my quandary. That
solves my problem. The only question remaining is, "Where in the world would
I find documentation for the information that you provided? I consulted
reference books and Access help, but couldn't find a clue to that
information."

Thanks again.
 

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