none
Link a Drop Down Box to an Address Field RRS feed

  • Question

  • I am trying to Create a form where if you choose your branch name then it will autopopulate the address at the top corner. Is there a way to link a drop down menu to and address field or text field to show an information based on the option chosen for the drop down? 

    This is for Microsoft Word 2010.


    **LAYMANS TERM would be great!*
    Friday, January 10, 2014 4:44 PM

All replies

  • Are we discussing Word here, or something else? If Word, which version?

    What kind of form, built with which technology and programming language?


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, January 10, 2014 5:06 PM
    Moderator
  • I'm sorry I should have clarified that.  It's Word 2010
    I am using the Legacy forms but am open to suggestions
    Friday, January 10, 2014 7:00 PM
  • If I have understood correctly, then yes. Suppose your form field dropdown is "dropdown1", and you had dropdown values "abc", "def", "ghi". Then you can use a nested field to construct the name of a Custom Document Property, a Bookmark, or a Document Variable (for example) and inserts the value into the document. If the dropdown is set to "Calculate on Exit", the field will update automatically when the user tabs from the field. No VBA is required while the document is running, only (at most) to set up the addresses.

    Document Variables can be a good choice because naming is flexible (so you can have, spaces in the dropdown values). In that case the field might look like this:

    { DOCVARIABLE "address_{ REF dropdown1 }" }

    (where all the {} are the special field code brace pairs that you can insert using ctrl-F9 on Windows Word). You would need Document Variables called "address_abc", "address_def", "address_ghi"). You can create/modify such variables in VBA using, e.g.

    ActiveDocument.Variables("address_abc").Value = "First Address line" & vbCrLf & _
     "Second Address Line" & vbCrLf & _
    "etc."

    You can download a simple working example from http://goo.gl/AzsoAs




    Peter Jamieson

    Saturday, January 11, 2014 10:25 AM
  • You can easily create the docVariables Peter suggests using the add-in here:

    http://gregmaxey.mvps.org/word_tip_pages/cc_var_bm_doc_prop_tools_addin.html

    Greg Maxey Please visit my website at: http://gregmaxey.mvps.org/word_tips.htm

    Saturday, January 11, 2014 9:09 PM
  • Ok I've created the form and it is supposed to be for all of our different branches. I want there to be a drop down of the list of branches (Texas, OK, FL...etc) and the, based on the branch they choose, for the box at the top right corner to generate that branches address. This will cut down on discrepencies when several people are filling out the form. How do I do this inword? Is this possible. Please tell me step by step if so.

    Thursday, January 30, 2014 2:29 PM
  • Ok I've created the form and it is supposed to be for all of our different branches. I want there to be a drop down of the list of branches (Texas, OK, FL...etc) and the, based on the branch they choose, for the box at the top right corner to generate that branches address. This will cut down on discrepencies when several people are filling out the form. How do I do this inword? Is this possible. Please tell me step by step if so.

    Thursday, January 30, 2014 2:54 PM
  • Ok I've created the form and it is supposed to be for all of our different branches. I want there to be a drop down of the list of branches (Texas, OK, FL...etc) and the, based on the branch they choose, for the box at the top right corner to generate that branches address. This will cut down on discrepencies when several people are filling out the form. How do I do this inword? Is this possible. Please tell me step by step if so.

    Thursday, January 30, 2014 2:54 PM
  • I haven't looked at the suggestions that Greg has made, but assuming you didn't find what you wanted in there, I have posted an example at http://goo.gl/EUtloR that shows how you can do this using a "legacy" dropdown field, a REF field, with the addresses inserted in the document as hidden text. You will have to download it - if it opens in the Word Web App, you should be able to use File->Save As to do that, I think. The Word Web App does not process form fields so you cannot see what is going on in there.

    BTW, with legacy dropdowns there is a maximum of 25 entries.

    IN this case, I have to use a "branch code" that can be used to form a valid Word bookmark name, so I have used branch1, branch2, branch3.

    The dropdown field name is "branch". It has to be marked as "Calculate on Exit".

    The three sample address are formatted as hidden text, and bookmarked with names constructed by prefixing the values in the dropdown with "addr_", i.e. addr_branch1, addr_branch2, addr_branch3. (They could easily be just "branch1", "branch2" etc.). I have use line ends (shift-enter) rather than paragraph marks to terminate each line as you tend to get a better layout.

    The REF field at the top right is in a paragraph formatted as "right aligned" and has the following field code:

    { REF "addr_{ branch }" \*charformat }

    The \*charformat needs to be there or the results will be formatted the same as the  bookmarked texts, i.e. as hidden.

    I leave you to work out how to put your box around the address. I would probably use a single-cell table with a border.

    There is another example which does something similar but uses Document variables - it doesn't address your problem directly but you may find it useful:
    http://goo.gl/AzsoAs


    Peter Jamieson

    Thursday, January 30, 2014 3:37 PM
  • Hi Jessica

    What you want to do has a certain level of complexity, but is completely possible, using VBA code (a macro). I don't think anyone in this forum (which targets developers - people who write code for a living) is going to tell you, step-by-step, how to accomplish it.  That would take hours of effort! This is not a place to get free solutions. People who help out here voluntarily provide assistance based on their experience, but they don't do the work for others. You've been given a number of suggestions how to approach the task, all of them completely valid, with sample code. You'll need to buckle down and work your way through them.


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, January 30, 2014 6:13 PM
    Moderator