Other Useful Items

There are a few other useful things that you can do when designing a user form. You might notice that the text boxes are aligned with the labels, and the left and right margins of each are also aligned. If you attempt to do this using only your eyes, you may have some difficulty. The easiest way to do this is to make the sizes the same using the properties dialog's height and width properties. You can drag one text box or label to the right size, look at the height and width properties, and set the properties of the other text boxes to be the same. Then, when you want to align the text boxes or labels, click and drag to select the text boxes or labels that you want to align, go to the top menu and select Format Align, and choose whether you want Lefts, Right, Tops, Bottoms, Centers, or Middles. This automatically lines up your controls.

If you need the user to enter a range, there is an object that you can put on a user form that makes it very easy to do. It is called the RefEdit control and is on the bottom left of the control toolbox. When you put it on the user form, the user clicks on it and selects a range which is stored as a text value A1-style reference and can be retrieved using the Value property.

The other control that I use quite a bit is the MultiPage control. This lets you use one form while allowing you to gather a lot more information. It also makes it nice when you want to break up the data entry into pieces. I have used this control in cases ...

Get Integrating Excel and Access now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.