Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Sep 2004
    Location
    Sydney, New South Wales, Australia
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Populate combo box & maintain info (2000 sp3)

    I would like some advise on the best way to manage information used to populate a number of combo boxes and associated text boxes.

    I have a template with a userform. The userform has three combo boxes and one or two text boxes associated with each of the combo boxes as shown in the attachment.

    The combo boxes display the names of employees, each combo box has different combinations of employees and some employees can appear in more than one combo box. When a name is selected the position title is shown in the associated text box. The user can also enter a different name and title.

    There are a total of 12 names and positions that are currently hard coded in the userform code.

    The names do not change very often, however, I would like to have a way of being able to change or add names and positions, that does not involve changing the code. The method must also be simple to use (and hopefully relatively simple to code).

    I have searched the database and there appear to be several ways of achieving what I require, however, before I start, some advise on the best way of achieving it would be appreciated.
    Attached Images Attached Images

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Populate combo box & maintain info (2000 sp3)

    You could store the information in a text file, for example in a .ini file. Word can read .ini files using System.PrivateProfileString.

    An ini file consists of one or more sections denoted by [SectionName] and entries of the form EntryName=Value. For example:

    [Employees]
    Count=3
    Item1=John
    Item2=Mary
    Item3=David

    Code to populate a combo box could look like this:

    Dim i As Integer
    Dim n As Integer
    Const strPath = "C:Settings.ini"
    n = System.PrivateProfileString(strPath, "Employees", "Count")
    For i = 1 To n
    Me.cboEmployees.AddItem System.PrivateProfileString(strPath, "Employees", "Item" & i)
    Next i

    The ini file can be created and edited in any text editor, for example Notepad.

  3. #3
    Star Lounger
    Join Date
    Sep 2004
    Location
    Sydney, New South Wales, Australia
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Populate combo box & maintain info (2000 sp3)

    Thanks Hans

    Your suggestion is a simple solution, and would work very well if I was the only one who altered the ini file. However, my concern is that if the person altering the ini file does not understand what he/she is doing the ini file could by damaged. Would it be possible to have a Word template with a table that held the information and have that template loaded into the 'Briefing' template as an addin, then use the information in the table to populate the combo boxes and text boxes?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Populate combo box & maintain info (2000 sp3)

    You can store the info in a Word document (I wouldn't use an add-in for this; add-ins are not meant to contain text, just code, userforms etc.), or in an Excel spreadsheet, or in an Access database. But the user might damage those as well.

  5. #5
    Star Lounger
    Join Date
    Sep 2004
    Location
    Sydney, New South Wales, Australia
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Populate combo box & maintain info (2000 sp3)

    Thanks for the advise Hans
    I will have a think about my options, I am tending towards the .ini file option and placing the .ini file in the network templates folder.

  6. #6
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Populate combo box & maintain info (2000 sp3)

    To avoid unwanted changes to templates and ini files, we made the Workgrouptemplates folder read-only for anyone but system admins, using permissons in the network OS (Novell in our case).

Posting Permissions

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