Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Jul 2002
    Thanked 0 Times in 0 Posts

    Dynamically add textboxes to form (2000)

    I need a maximum number of input lines on a form because I have to limit the number of lines on the form to the number of lines that will fit on a section of the page in the report (let's say 10 lines for example).

    It would be easy if it was it could be one long memo field occupying 10 lines, or 10 textboxes each occupying one line. But it could be either of those anything in between. For example, I could have 2 textboxes: a 7 line comment, then a 3 line comment for a total of 10 lines. Oh yeah, each line is preceded by an associated time stamp.

    In another thread we worked out the code for getting the report to print each line of the memo as a separate line on the report. Post 197703 shows my example, and post 198714 shows Mark D's example and code.

    I have a function to count the number of total lines from the multiple text boxes, but here's where I need some help.

    Option 1) I can put 10 comment textboxes (an timestamp textboxes) on the form and keep a running count of how many lines they expand too. If the first text box goes to 7 lines and the second goes to 3 lines, then I've got 10 lines, I'm full, I can delete the remaining textboxes.

    Option 2) Add textboxes as needed. Start with one textbox. On exiting, count the lines, and if there's less than 10, add another text box to the form. Keep a running count of the lines in all the textboxes. After exiting textbox 2, if there' s still less than 10 lines total on the form, present another text box. Option 2 seems a little more elegant than starting with 10 textboxes.

    I need some insight into how to dynamically add or delete objects on a form. First of all is it doable?


  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: Dynamically add textboxes to form (2000)

    You can't create or delete controls while the form is "running", only in design view (interactivley or in code). But you *can* make controls visible and invisible. So I would suggest adding the maximum number of text boxes you will need in design view. You might for instance set the Visible property for all but the first one to No. Then, you'd need to have code that sets the Visible property of the second text box to True when it's needed, then that of the third one, etc.

Posting Permissions

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