Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Dec 2011
    Posts
    30
    Thanks
    2
    Thanked 0 Times in 0 Posts

    SpinButton to automatically add columns

    Hi uber geniuses!

    I've got a couple of queries, but I've separated them across different threads - I hope that's ok! I thought it would make it easier.

    For this one, if I were to make the spinbutton on DirectorsPage have a max of 100, could I then make it insert a column in the appropriate place? I.e, there are currently enough Director columns in the spreadsheet for 5 Directors. Say the user enters 20 as the number of directors, and I code the userform to show 20 director fields, if there is text in Director20, can I make the spreadsheet enter in columns for Director6 to Director20 after the Director5 column automatically, so that I can then input the text from those text boxes into the fields?

    This will affect my offsetting as well, but Iím not sure how to go about it.

    I've attached my test database so you can see what I mean. I know my coding is horrible - forgive me, I'm a beginner!

    Help!.zip

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    I would structure this differently by using relational data. This means you have one table with the OMB Agents details. Then a separate table holds all the directors names and addresses PLUS a column which indicates which OMB Agent the director is associated with. This then eliminates the need to dynamically add field names as more directors come onboard - you just add another record (line).

    Then for the user interface, I would display the list of directors in a single listbox or combobox since these items allow you to add as many records (directors) as you like. If you need to edit these values there could be a single set of fields along with a set of Add, Delete and Edit buttons.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    Lounger
    Join Date
    Dec 2011
    Posts
    30
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Hi Andrew!

    Thanks so much for your help. Your answer has helped me realise that I'm probably making things more difficult than they need to be.

    Essentially, all of the columns in the sheet will be merge fields for a suite of documents, so I'm not sure I could split the tables up like you suggest I would need to do to make this work. I guess I was just trying to be tricky! The client I am doing this for is not very IT-minded (I'm a WP operator, so I generally just format things, and can create complex templates and precedents based on fields/formulas/merges, but I was trying to go one step further on this one), and I've just realised if I don't have finite merge fields in the documents (say, a maximum of 20 directors), they might have to go in to the templates themselves and adjust them (unless that's wrong?). I think that would scare them.

    However, I will keep playing around with this, because I'm sure it will come in handy on another project! I'll develop something and let you know if I have any more questions.

    Thanks so much for your help!

Posting Permissions

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