PDA

View Full Version : Form position



dzogchen
03-26-2011, 02:39 PM
Hello all,

I'm trying to automate some registrations procedures at work with VBA. I'm thinking in one main form with about 10 textboxes with vertical displacement where we write numbers. When we click in each textbox a second form will appear to register an additional information.

To make things more practical I'm trying to positioning the second form near each textbox, with a little offset. Is that possible?

Regards

Aussiebear
03-26-2011, 03:18 PM
I'm thinking in one main form with about 10 textboxes with vertical displacement where we write numbers. When we click in each textbox a second form will appear to register an additional information.

You can set a textbox to gain focus in an order, which enables you to write to the textbox. Once you write "the Numbers" and either press Enter or Tab the focus moves elsewhere. By suggesting that you "click in each textbox" would you not be better off setting the textboxes up as a cmdbutton instead, to load each additional form as and when required?


To make things more practical I'm trying to positioning the second form near each textbox, with a little offset. Is that possible?

Forms can be given a position by their properties.

Please upload a sample of what you are intending so we can review what's happening?

Regards[/quote]

dzogchen
03-26-2011, 04:10 PM
The nearest result that i got for what I inted to do was with the following code:

Private Sub TextBox2_Enter()
Load UserForm2
UserForm2.StartUpPosition = 0
UserForm2.Top = UserForm1.Top
UserForm2.Left = UserForm1.Left
UserForm2.Show
End Sub

which give the following result
http://www.megagaleria.com/pictures/Pic_4719_28.jpg

But what would like is:
http://www.megagaleria.com/pictures/Pic_4719_26.jpg

if I click on textbox1 and
http://www.megagaleria.com/pictures/Pic_4719_27.jpg

if I click on textbox2

dzogchen
03-26-2011, 04:12 PM
Form OnLoad near the textbox that I clicked

mikerickson
03-26-2011, 04:20 PM
If the sub-forms are just (single select) checkboxes, you'd probably be better off using ComboBoxes instead of TextBoxes and avoiding the multiple userforms.

If you don't like the look of the button on a combobox, you can set .ShowDropButtonWhen to 0 (never) and have each box have an Enter event like
Private Sub ComboBox1_Enter()
ComboBox1.DropDown
End Sub

dzogchen
04-02-2011, 05:19 AM
Hello,

I develop a code that do what I want:

Private Sub UserForm_Initialize()
UserForm2.StartUpPosition = 0
UserForm2.Top = UserForm1.Top + 80
UserForm2.Left = UserForm1.Left + 70
End Sub

This way the UserForm2 is dependent of the UserForm1 up left corner position and appears near Textboxes giving more comfort to choose the additional options.