Consulting

Results 1 to 6 of 6

Thread: Form position

  1. #1
    VBAX Regular
    Joined
    Apr 2007
    Posts
    41
    Location

    Form position

    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

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,091
    Location
    Quote Originally Posted by dzogchen
    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]
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  3. #3
    VBAX Regular
    Joined
    Apr 2007
    Posts
    41
    Location
    The nearest result that i got for what I inted to do was with the following code:

    [vba] Private Sub TextBox2_Enter()
    Load UserForm2
    UserForm2.StartUpPosition = 0
    UserForm2.Top = UserForm1.Top
    UserForm2.Left = UserForm1.Left
    UserForm2.Show
    End Sub
    [/vba]
    which give the following result


    But what would like is:


    if I click on textbox1 and


    if I click on textbox2

  4. #4
    VBAX Regular
    Joined
    Apr 2007
    Posts
    41
    Location
    Form OnLoad near the textbox that I clicked

  5. #5
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    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
    [VBA]Private Sub ComboBox1_Enter()
    ComboBox1.DropDown
    End Sub[/VBA]

  6. #6
    VBAX Regular
    Joined
    Apr 2007
    Posts
    41
    Location
    Hello,

    I develop a code that do what I want:

    [vba]Private Sub UserForm_Initialize()
    UserForm2.StartUpPosition = 0
    UserForm2.Top = UserForm1.Top + 80
    UserForm2.Left = UserForm1.Left + 70
    End Sub
    [/vba]
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •