Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 07-31-2019, 06:29 AM
gmayor's Avatar
gmayor gmayor is offline Can a text form field be dependent on a drop-down? Windows 10 Can a text form field be dependent on a drop-down? Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Assuming the list box is titled 'Country' and the others are titled "Short Name" the following macro in he thisdocument module will fill the short name fields with the selection from the country as US or MEX. You may find Insert Content Control Add-In useful

Code:
Option Explicit

Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim oCC As ContentControl
    If ContentControl.ShowingPlaceholderText = False Then
        If ContentControl.Title = "Country" Then    'the title of the list box control
            Select Case Trim(ContentControl.Range.Text)
                Case "United States"
                    For Each oCC In ActiveDocument.ContentControls
                        If oCC.Title = "Short Name" Then    'the title of the fields used for the short version
                            oCC.Range.Text = "US"
                        End If
                    Next oCC
                Case "Mexico"
                    For Each oCC In ActiveDocument.ContentControls
                        If oCC.Title = "Short Name" Then
                            oCC.Range.Text = "MEX"
                        End If
                    Next oCC
                    'etc
            End Select
        End If
    End If
    Set oCC = Nothing
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 

Tags
dropdown, form fill, legacy form



Similar Threads
Thread Thread Starter Forum Replies Last Post
Activate (show) a Drop-down form field when another drop-down form field is selected from Jentis Word VBA 1 04-19-2018 09:42 PM
Can a text form field be dependent on a drop-down? Auto Populate Text On Dependent Drop Down Exit GregStewartPTC Word VBA 2 02-27-2017 05:37 AM
make text form field active dependent on dropdown Glenn0004 Word VBA 1 06-23-2015 06:13 PM
form control Field - Drop down auto text mrtinfl Word 5 11-19-2014 06:57 AM
Can a text form field be dependent on a drop-down? Form Field - Drop down selection causing auto text chesspupil Word VBA 7 05-09-2010 05:43 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:43 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft