none
Populating a VBA form with text box's using code RRS feed

  • Question

  • What I wish to do is to populate a form (actually a multipage on a form) with text box's and accompanying labels based on the column headings of a specified table.

    This is for a data entry screen for a table, maximum of 2 digits per textbox. (and yes, I am well aware that this would be better handled by a database, unfortunately, that is not an option)

    I have extracted the column headings into a string array.

    now I need to do the following

    determine how many rows of n columns of text box's and labels are needed ( my preference is for labels above text box's)

    determine spacing between columns

    determine the width of the text box's / labels (longest column name)

    determine the size of the multipage

    resize the form and multipage if needed

    At this point, I am unsure on how to find the boundaries of the multipage, the rest I can kludge something together, how ever if someone has a nice elegant algorithm to work out the columns / rows required and the spacing I would love to see it

    Thanks in advance

    Kim

     
    Monday, December 22, 2014 8:21 AM

Answers

  • Hi Kim,

    Thanks for posting in MSDN forum.

    >>At this point, I am unsure on how to find the boundaries of the multipage, the rest I can kludge something together, how ever if someone has a nice elegant algorithm to work out the columns / rows required and the spacing I would love to see it<<

    As far as I know, we can get the four property relative to the boundaries of multipage. There are left, top, width and height.

    But it is difficult to determine the width of labels, you may can try to get the width via the length of string. I think a bettor way is we can fix the number of column(for example, tow labels and two textboxes on one row) then add the labels and textbox on the different rows. And we can set the width of label via the longest string.

    Here is the code to get the boundaries of multipage:

    Debug.Print "Left:" & MultiPage1.Left
    Debug.Print "Top:" & MultiPage1.Top
    Debug.Print "Width:" & MultiPage1.Width
    Debug.Print "Height:" & MultiPage1.Height

    Hope it is helpful.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, December 23, 2014 3:37 AM
    Moderator

All replies

  • Hi Kim,

    Thanks for posting in MSDN forum.

    >>At this point, I am unsure on how to find the boundaries of the multipage, the rest I can kludge something together, how ever if someone has a nice elegant algorithm to work out the columns / rows required and the spacing I would love to see it<<

    As far as I know, we can get the four property relative to the boundaries of multipage. There are left, top, width and height.

    But it is difficult to determine the width of labels, you may can try to get the width via the length of string. I think a bettor way is we can fix the number of column(for example, tow labels and two textboxes on one row) then add the labels and textbox on the different rows. And we can set the width of label via the longest string.

    Here is the code to get the boundaries of multipage:

    Debug.Print "Left:" & MultiPage1.Left
    Debug.Print "Top:" & MultiPage1.Top
    Debug.Print "Width:" & MultiPage1.Width
    Debug.Print "Height:" & MultiPage1.Height

    Hope it is helpful.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, December 23, 2014 3:37 AM
    Moderator
  • Thanks for the reply, sry about not responding earlier, been awol
    Wednesday, January 14, 2015 12:38 AM