Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2007

Tip: Looking for answers? Try searching our database.

Selection of two drop-down form filelds decide selection in third drop-dn form field?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Archie - 12 Jan 2007 16:44 GMT
I have a scenario where I need a drop-down form field to automatically
select a specific selection based on the selection of two separate
drowndown formfields.  All of this is in the same template, but the
form field are in separate tables.  I would likely just use the
selection method to handle that issue.

In each of the two primary dropdown form fields there are 5 possible
choices.  I have already figured out the possible comboniations for the
thrid drop-down form field via a mathematial formula, just need help on
the basic coding structure so I can implement my logic.

The reason I am coding it this way is because the third drop-down form
field that I need pre-selected is a strong suggestion to the user of
the template for that specific selection.  But, I do want to give them
the ability to make an alternate selection within the drop-down form
field choices.

If someone could point me in the correct direction I would truly
appreciate it very much.  I am working in MS Word 2003 in a proteted
doc (template).  

Thank you,

Arche
Doug Robbins - Word MVP - 12 Jan 2007 18:58 GMT
The command

ActiveDocument.FormFields("Dropdown1").DropDown.Value

returns the position in the list (starting from 1) of the item that is
selected in a DropDown FormField.

With a document containing 3 DropDown Formfields:

Dropdown1, Dropdown2 and Dropdown3

with the Dropdown3 FormField containing the entries

11, 12, 13, 14, 15, 21, 22, 23, 24, 25, 31, 32, 33, 34, 35, 41, 42, 43, 44,
45, 51, 52, 53, 54, 55

and with the following code in a run on exit from the Dropdown2 FormField

Sub DDCode()
DD1 = ActiveDocument.FormFields("Dropdown1").DropDown.Value
DD2 = ActiveDocument.FormFields("Dropdown2").DropDown.Value
ActiveDocument.FormFields("Dropdown3").Result = 10 * DD1 + DD2
End Sub

the Dropdown3 formfield will display the number that is the result of adding
the index of the Dropdown2 formfield to 10 times the index of the Dropdown1
formfield.

That is if the second item is selected in Dropdown1 and the third item is
selected in Dropdown2, Dropdown3 will display 23.

You will have to need to come up with a way to reduce all of the 25
possibilities to the give the appropriate result and for that purpose, you
would most likely use a Select Case construction.

Rather than using DropDown FormFields in a protected document, I would be
doing this with comboboxes in a UserForm.

See the article "How to create a Userform" at:

http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm

For a number of reasons, I would not try to do this with formfields in a
protected document

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

>I have a scenario where I need a drop-down form field to automatically
> select a specific selection based on the selection of two separate
[quoted text clipped - 20 lines]
>
> Arche
Archie - 12 Jan 2007 20:09 GMT
Doug, many thanks for your response.  You mentioned at the end of your
posting that you would not try to do this with formfields in a
protected document.  Would you mind helping me understand this a little
better as I am unclear of where you were going with that and I am
always interested in developing the best solution.  You also mentioned
using combo boxes as opposed to dropdown form field.  I want to
hopefully understand your logic a little better there as well.

In order to clarify, I am not going to be performing math on the result
of the dropdown fields 1 and 2.  I am attempting to pre-select a
specific option in the dropdown list in the third dropdown field.  So
for example, the choices in dropdown1 in a case statement might be
"item 1", item 2...item 5.  The choices in dropdown 2 migh be "element
1".... "element5".  Now, based on the selection in dropdown1 AND
dropdown 2 I want to pre-select one of five choices ("choice
1"..."choice 5") in dropdown3.  Hopefully this makes sense.  If using
dropdown3 presents a problem, I am open to using a text field and
calling it a "recommendation" as opposed to the logic that I was trying
to implement.

Thank you.

-Arche

> The command
>
[quoted text clipped - 73 lines]
> >
> > Arche
Doug Robbins - Word MVP - 12 Jan 2007 22:12 GMT
A combobox is to a userform as a dropdown formfield is to a protected
document.

I gather that you want some action taken following the acceptance (or
alternate selection) of the item in dropdown3.  For that purpose, I consider
a userform a better tool for the job than a form in a protected document.

Aside from that, my use of a bit of mathematics was just a way of coming up
with a unique value for every possible combination of the selections that
may be made in the first and second dropdowns, of which there are 25
possibilities.  I gather than you need, by some sort of grouping, reduce
these 25 possibilities to 5 possibilities.  As mentioned, that would best be
done with the user of a Select Case construction, though it could also be
done with a series of If...then...Else constructions.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Doug, many thanks for your response.  You mentioned at the end of your
> posting that you would not try to do this with formfields in a
[quoted text clipped - 101 lines]
>> >
>> > Arche
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.