From: johnnykunst on 24 May 2010 06:36 I wasnt to automate a text entry on a form I'm working on; in a drop down list, the user selects a category and dependent on what they select, I want a text form field to populate with text (in this case a description of the category they have selected) So for example, if they select DRI from the drop down list, the text field populates with "Drug Related Information", if they select CASB the text field is populated with "Crime & Anti Social Behaviour". I'm using Word 2003. Thanks to anyone who can help- have scoured the internet for a couple of hours but found nothing. --- frmsrcurl: http://msgroups.net/microsoft.public.word.vba.general
From: Graham Mayor on 24 May 2010 07:11 If your form will allow the use of macros then it is failrly simple to do that - the process is more or less that described at http://www.gmayor.com/SelectFile.htm, but while you can put the result in a text form field, it might be better to apply it to a docvariable and use a docvariable field - here {DocVariable "varText"} - to display the result as in the second example Add as many case statements as you have entries in your dropdown field Sub OnExitDD1() 'fills text field based on content of _ dropdown field Dim oFld As FormFields Set oFld = ActiveDocument.FormFields Select Case oFld("Dropdown1").Result Case Is = "CASB" oFld("Text1").Result = "Crime & Anti Social Behaviour" Case Is = "Something else" oFld("Text1").Result = "Text associated with something else" Case Else 'Do nothing End Select End Sub OR Sub OnExitDD1() Dim oFld As FormFields Dim oVars As Variables Set oFld = ActiveDocument.FormFields Set oVars = ActiveDocument.Variables Select Case oFld("Dropdown1").Result Case Is = "CASB" oVars("varText").Value = "Crime & Anti Social Behaviour" Case Is = "Something Else" oVars("varText").Value = "Text associated with something else" Case Else 'Do nothing End Select ActiveDocument.Fields.Update End Sub If your form does not use macros then you can use a sequence of conditional fields on the same line e.g. {IF {REF Dropdown1} = "CASB" "Crime & Anti Social Behaviour"}{IF {REF Dropdown1} = "Something Else" "The text associated with something else"}etc This assumes the fieldname is Dropdown1 and that you have checked the calculate on exit check box of the dropdown field to force an update to the conditional field. Note that this won't work without macros if the fields are in the document header/footer. -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>>< ><<> <>>< <>><<> "johnnykunst" <user(a)msgroups.net/> wrote in message news:On541zy%23KHA.4308(a)TK2MSFTNGP04.phx.gbl... >I wasnt to automate a text entry on a form I'm working on; in a drop down >list, the user selects a category and dependent on what they select, I want >a text form field to populate with text (in this case a description of the >category they have selected) So for example, if they select DRI from the >drop down list, the text field populates with "Drug Related Information", >if they select CASB the text field is populated with "Crime & Anti Social >Behaviour". > I'm using Word 2003. > Thanks to anyone who can help- have scoured the internet for a couple of > hours but found nothing. > > --- > frmsrcurl: http://msgroups.net/microsoft.public.word.vba.general
From: johnnykunst on 24 May 2010 10:18 Works brilliantly, thank you. --- frmsrcurl: http://msgroups.net/microsoft.public.word.vba.general/Dependant-text-entry
|
Pages: 1 Prev: Extract section of text from a form field Next: Delete a command button on a protected sheet |