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 / March 2006

Tip: Looking for answers? Try searching our database.

need code to select one drop down option based on a previous drop

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
fiddleman - 09 Mar 2006 18:26 GMT
I am looking for the code to auto select a value on one form field from input
on a previous one.  The form fields could be drop downs ....or as simple as
checkboxes.
i.e. if one checkbox is checked, I want the other to autocheck as well....or
its value to be true. If a certain selection is made in the first drop-down
box, a certain selection should be set in the second drop-down.
Chris Marlow - 10 Mar 2006 08:45 GMT
Hi,

You can use the 'Run macro on', 'Exit' on the Field Options dialog for the
form item to set a macro that sets the value in the other field. If I
remember rightly you set the Bookmark property of the field here to 'name'
the form field (so you access it through bookmarks).

Regards,

Chris.

Signature

Chris Marlow
MCSD.NET, Microsoft Office XP Master

> I am looking for the code to auto select a value on one form field from input
> on a previous one.  The form fields could be drop downs ....or as simple as
> checkboxes.
> i.e. if one checkbox is checked, I want the other to autocheck as well....or
> its value to be true. If a certain selection is made in the first drop-down
> box, a certain selection should be set in the second drop-down.
Greg - 10 Mar 2006 13:05 GMT
Fiddle stroker,

Here is some examples of controling one text field with another, one
checkbox with another and one dropdown with another.  You could of
course adapt a necessary:

Sub ROE()
Dim oFFld As FormFields
Set oFFld = ActiveDocument.FormFields
On Error Resume Next
ActiveDocument.Unprotect
On Error GoTo 0
If oFFld("Text1").Result = "Hello" Then
 oFFld("Text2").Result = "World"
Else
 oFFld("Text2").Result = " "
End If
If oFFld("Check1").CheckBox.Value = True Then
 oFFld("Check2").CheckBox.Value = True
Else
 oFFld("Check2").CheckBox.Value = False
End If
Select Case oFFld("DropDown1").Result
 Case "A"
   oFFld("DropDown2").Result = "Apples"
 Case "B"
   oFFld("DropDown2").Result = "Broomsticks"
 Case Else
   'Do nothing
End Select
ActiveDocument.Protect wdAllowOnlyFormFields, NoReset:=True
End Sub

To test, enter two text fields, two check boxes and two dropdowns in a
document.  Enter A and B as options in the first dropdown.

Set the ROE macor to "Run on Exit" from the first text, checkbox, and
dropdown.

HTH
fiddleman - 10 Mar 2006 15:04 GMT
Greg thanks so much ...that was exactly what I needed...

> Fiddle stroker,
>
[quoted text clipped - 36 lines]
>
> HTH
Greg - 10 Mar 2006 16:27 GMT
Fiddle stroker.

My pleasure.
 
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.