Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Conditional Dropdown List in a Word Form
I am creating a form for use in my company. The user needs to list the
category code, and sub-category code, for an item. I was asked to build a dropdown list for each field. I had no problem creating the dropdown for the category code (there are only 8). But there are more than 25 sub-categories. The ideal would be that, afterthe user selects a category code, when clicking on the sub-category field, a dropdown displays only the sub-cat codes associated with the chosen category. That would make the form easy to use, AND overcome the 25-row limit in WORD dropdowns. Is there a way to do this without becoming a visual basic programmer? -- Not-A-Programmer |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Conditional Dropdown List in a Word Form
Leesa
Is there a way to do this without becoming a visual basic programmer? Yes, get someone to do it for you ;-) This should get your started. Set the macro to run on exit form the Category dropdown field: Sub PopulateSubCat() Dim oFld As FormFields Set oFld = ActiveDocument.FormFields Select Case oFld("Cat").Result Case Is = "A" With oFld("SubCat").DropDown .ListEntries.Clear .ListEntries.Add "Apples" .ListEntries.Add "Apricots" .Value = 1 End With Case Is = "B" With oFld("SubCat").DropDown .ListEntries.Clear .ListEntries.Add "Blueberries" .ListEntries.Add "Bananas" .Value = 1 End With Case Is = "C" 'Etc. End Select End Sub -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. "Leesa" wrote in message news I am creating a form for use in my company. The user needs to list the category code, and sub-category code, for an item. I was asked to build a dropdown list for each field. I had no problem creating the dropdown for the category code (there are only 8). But there are more than 25 sub-categories. The ideal would be that, afterthe user selects a category code, when clicking on the sub-category field, a dropdown displays only the sub-cat codes associated with the chosen category. That would make the form easy to use, AND overcome the 25-row limit in WORD dropdowns. Is there a way to do this without becoming a visual basic programmer? -- Not-A-Programmer |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Conditional Dropdown List in a Word Form
Greg,
I created a macro TRYING to use your code, and (surprise) I got an error message: "Compile error: Sub or Function not defined." The first row was highlighted in yellow, but I don't know if that's the problem child or not. Here's the code I typed: Sub PopulatesSubCat() ' ' AddToDXTGViaMenu Macro ' Macro created 8/24/2006 by Leesa Dupree ' Display a dropdown list of only the subcategory codes associated with the category code selected in the Categories field. Dim oFld As FormFields Set oFld = ActiveDocument.FormFields Select Case oFld("Categories").Result Case Is = "1 Recliners" With oField("SubCat").DropDown .ListEntries.Clear .ListEntries.Add "104 Zero Gravity" .ListEntries.Add "106 Lift Chairs" .ListEntries.Add "108 Outdoor" .ListEntries.Add "109 Stationary" .Value = 1 End With Case Is = "2 Office" With oField("SubCat").DropDown .ListEntries.Clear .ListEntries.Add "211 Moveable W/S" .ListEntries.Add "213 Other" .ListEntries.Add "214 Desks" .ListEntries.Add "222 Management Chairs" .ListEntries.Add "223 Task Chairs" .ListEntries.Add "224 Executive Chairs" .ListEntries.Add "225 Specialty Chairs" .Value = 1 End With End Select End Sub (I decided to try this with just the first two sub-cats, to see if it would work.) The two relevant fields in the form are bookmarked (in the Properties box), respectively, as "Categories" and "Subcat". However, the prompts in the form for the two fields read, respectively, "Category:" and "Sub-Category:" I'm not sure if this is relevant to the de-bugging or not. Any suggestions for me? Where did I go wrong? -- Not-A-Programmer "Greg Maxey" wrote: Leesa Is there a way to do this without becoming a visual basic programmer? Yes, get someone to do it for you ;-) This should get your started. Set the macro to run on exit form the Category dropdown field: Sub PopulateSubCat() Dim oFld As FormFields Set oFld = ActiveDocument.FormFields Select Case oFld("Cat").Result Case Is = "A" With oFld("SubCat").DropDown .ListEntries.Clear .ListEntries.Add "Apples" .ListEntries.Add "Apricots" .Value = 1 End With Case Is = "B" With oFld("SubCat").DropDown .ListEntries.Clear .ListEntries.Add "Blueberries" .ListEntries.Add "Bananas" .Value = 1 End With Case Is = "C" 'Etc. End Select End Sub -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. "Leesa" wrote in message news I am creating a form for use in my company. The user needs to list the category code, and sub-category code, for an item. I was asked to build a dropdown list for each field. I had no problem creating the dropdown for the category code (there are only 8). But there are more than 25 sub-categories. The ideal would be that, afterthe user selects a category code, when clicking on the sub-category field, a dropdown displays only the sub-cat codes associated with the chosen category. That would make the form easy to use, AND overcome the 25-row limit in WORD dropdowns. Is there a way to do this without becoming a visual basic programmer? -- Not-A-Programmer |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Conditional Dropdown List in a Word Form
Leesa,
In your "With" statements you need to change oField to oFld. You are now a budding programmer ;-) -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Leesa wrote: Greg, I created a macro TRYING to use your code, and (surprise) I got an error message: "Compile error: Sub or Function not defined." The first row was highlighted in yellow, but I don't know if that's the problem child or not. Here's the code I typed: Sub PopulatesSubCat() ' ' AddToDXTGViaMenu Macro ' Macro created 8/24/2006 by Leesa Dupree ' Display a dropdown list of only the subcategory codes associated with the category code selected in the Categories field. Dim oFld As FormFields Set oFld = ActiveDocument.FormFields Select Case oFld("Categories").Result Case Is = "1 Recliners" With oField("SubCat").DropDown .ListEntries.Clear .ListEntries.Add "104 Zero Gravity" .ListEntries.Add "106 Lift Chairs" .ListEntries.Add "108 Outdoor" .ListEntries.Add "109 Stationary" .Value = 1 End With Case Is = "2 Office" With oField("SubCat").DropDown .ListEntries.Clear .ListEntries.Add "211 Moveable W/S" .ListEntries.Add "213 Other" .ListEntries.Add "214 Desks" .ListEntries.Add "222 Management Chairs" .ListEntries.Add "223 Task Chairs" .ListEntries.Add "224 Executive Chairs" .ListEntries.Add "225 Specialty Chairs" .Value = 1 End With End Select End Sub (I decided to try this with just the first two sub-cats, to see if it would work.) The two relevant fields in the form are bookmarked (in the Properties box), respectively, as "Categories" and "Subcat". However, the prompts in the form for the two fields read, respectively, "Category:" and "Sub-Category:" I'm not sure if this is relevant to the de-bugging or not. Any suggestions for me? Where did I go wrong? Leesa Is there a way to do this without becoming a visual basic programmer? Yes, get someone to do it for you ;-) This should get your started. Set the macro to run on exit form the Category dropdown field: Sub PopulateSubCat() Dim oFld As FormFields Set oFld = ActiveDocument.FormFields Select Case oFld("Cat").Result Case Is = "A" With oFld("SubCat").DropDown .ListEntries.Clear .ListEntries.Add "Apples" .ListEntries.Add "Apricots" .Value = 1 End With Case Is = "B" With oFld("SubCat").DropDown .ListEntries.Clear .ListEntries.Add "Blueberries" .ListEntries.Add "Bananas" .Value = 1 End With Case Is = "C" 'Etc. End Select End Sub -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. "Leesa" wrote in message news I am creating a form for use in my company. The user needs to list the category code, and sub-category code, for an item. I was asked to build a dropdown list for each field. I had no problem creating the dropdown for the category code (there are only 8). But there are more than 25 sub-categories. The ideal would be that, afterthe user selects a category code, when clicking on the sub-category field, a dropdown displays only the sub-cat codes associated with the chosen category. That would make the form easy to use, AND overcome the 25-row limit in WORD dropdowns. Is there a way to do this without becoming a visual basic programmer? -- Not-A-Programmer |
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Conditional Dropdown List in a Word Form
Greg,
Thank, thank you! It worked!!! -- Not-A-Programmer "Greg Maxey" wrote: Leesa, In your "With" statements you need to change oField to oFld. You are now a budding programmer ;-) -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Leesa wrote: Greg, I created a macro TRYING to use your code, and (surprise) I got an error message: "Compile error: Sub or Function not defined." The first row was highlighted in yellow, but I don't know if that's the problem child or not. Here's the code I typed: Sub PopulatesSubCat() ' ' AddToDXTGViaMenu Macro ' Macro created 8/24/2006 by Leesa Dupree ' Display a dropdown list of only the subcategory codes associated with the category code selected in the Categories field. Dim oFld As FormFields Set oFld = ActiveDocument.FormFields Select Case oFld("Categories").Result Case Is = "1 Recliners" With oField("SubCat").DropDown .ListEntries.Clear .ListEntries.Add "104 Zero Gravity" .ListEntries.Add "106 Lift Chairs" .ListEntries.Add "108 Outdoor" .ListEntries.Add "109 Stationary" .Value = 1 End With Case Is = "2 Office" With oField("SubCat").DropDown .ListEntries.Clear .ListEntries.Add "211 Moveable W/S" .ListEntries.Add "213 Other" .ListEntries.Add "214 Desks" .ListEntries.Add "222 Management Chairs" .ListEntries.Add "223 Task Chairs" .ListEntries.Add "224 Executive Chairs" .ListEntries.Add "225 Specialty Chairs" .Value = 1 End With End Select End Sub (I decided to try this with just the first two sub-cats, to see if it would work.) The two relevant fields in the form are bookmarked (in the Properties box), respectively, as "Categories" and "Subcat". However, the prompts in the form for the two fields read, respectively, "Category:" and "Sub-Category:" I'm not sure if this is relevant to the de-bugging or not. Any suggestions for me? Where did I go wrong? Leesa Is there a way to do this without becoming a visual basic programmer? Yes, get someone to do it for you ;-) This should get your started. Set the macro to run on exit form the Category dropdown field: Sub PopulateSubCat() Dim oFld As FormFields Set oFld = ActiveDocument.FormFields Select Case oFld("Cat").Result Case Is = "A" With oFld("SubCat").DropDown .ListEntries.Clear .ListEntries.Add "Apples" .ListEntries.Add "Apricots" .Value = 1 End With Case Is = "B" With oFld("SubCat").DropDown .ListEntries.Clear .ListEntries.Add "Blueberries" .ListEntries.Add "Bananas" .Value = 1 End With Case Is = "C" 'Etc. End Select End Sub -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. "Leesa" wrote in message news I am creating a form for use in my company. The user needs to list the category code, and sub-category code, for an item. I was asked to build a dropdown list for each field. I had no problem creating the dropdown for the category code (there are only 8). But there are more than 25 sub-categories. The ideal would be that, afterthe user selects a category code, when clicking on the sub-category field, a dropdown displays only the sub-cat codes associated with the chosen category. That would make the form easy to use, AND overcome the 25-row limit in WORD dropdowns. Is there a way to do this without becoming a visual basic programmer? -- Not-A-Programmer |
#6
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Conditional Dropdown List in a Word Form
Greg,
I was so jazzed when I got this to work ... you've been extremely helpful. Now please help me with the last step. When I saved the macro, it went into my "Normal" file. So when I emailed the form to the people who will actually be using it, the macro didn't go along for the ride. I could go to each user's PC and re-create the macro, but that seems terribly inefficient. How do I attach my macro to the form? -- Not-A-Programmer "Greg Maxey" wrote: Leesa, In your "With" statements you need to change oField to oFld. You are now a budding programmer ;-) -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Leesa wrote: Greg, I created a macro TRYING to use your code, and (surprise) I got an error message: "Compile error: Sub or Function not defined." The first row was highlighted in yellow, but I don't know if that's the problem child or not. Here's the code I typed: Sub PopulatesSubCat() ' ' AddToDXTGViaMenu Macro ' Macro created 8/24/2006 by Leesa Dupree ' Display a dropdown list of only the subcategory codes associated with the category code selected in the Categories field. Dim oFld As FormFields Set oFld = ActiveDocument.FormFields Select Case oFld("Categories").Result Case Is = "1 Recliners" With oField("SubCat").DropDown .ListEntries.Clear .ListEntries.Add "104 Zero Gravity" .ListEntries.Add "106 Lift Chairs" .ListEntries.Add "108 Outdoor" .ListEntries.Add "109 Stationary" .Value = 1 End With Case Is = "2 Office" With oField("SubCat").DropDown .ListEntries.Clear .ListEntries.Add "211 Moveable W/S" .ListEntries.Add "213 Other" .ListEntries.Add "214 Desks" .ListEntries.Add "222 Management Chairs" .ListEntries.Add "223 Task Chairs" .ListEntries.Add "224 Executive Chairs" .ListEntries.Add "225 Specialty Chairs" .Value = 1 End With End Select End Sub (I decided to try this with just the first two sub-cats, to see if it would work.) The two relevant fields in the form are bookmarked (in the Properties box), respectively, as "Categories" and "Subcat". However, the prompts in the form for the two fields read, respectively, "Category:" and "Sub-Category:" I'm not sure if this is relevant to the de-bugging or not. Any suggestions for me? Where did I go wrong? Leesa Is there a way to do this without becoming a visual basic programmer? Yes, get someone to do it for you ;-) This should get your started. Set the macro to run on exit form the Category dropdown field: Sub PopulateSubCat() Dim oFld As FormFields Set oFld = ActiveDocument.FormFields Select Case oFld("Cat").Result Case Is = "A" With oFld("SubCat").DropDown .ListEntries.Clear .ListEntries.Add "Apples" .ListEntries.Add "Apricots" .Value = 1 End With Case Is = "B" With oFld("SubCat").DropDown .ListEntries.Clear .ListEntries.Add "Blueberries" .ListEntries.Add "Bananas" .Value = 1 End With Case Is = "C" 'Etc. End Select End Sub -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. "Leesa" wrote in message news I am creating a form for use in my company. The user needs to list the category code, and sub-category code, for an item. I was asked to build a dropdown list for each field. I had no problem creating the dropdown for the category code (there are only 8). But there are more than 25 sub-categories. The ideal would be that, afterthe user selects a category code, when clicking on the sub-category field, a dropdown displays only the sub-cat codes associated with the chosen category. That would make the form easy to use, AND overcome the 25-row limit in WORD dropdowns. Is there a way to do this without becoming a visual basic programmer? -- Not-A-Programmer |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Word should catalog misspelled words to study. | Microsoft Word Help | |||
How to put graphics on envelopes? | Microsoft Word Help | |||
I am having difficulty with deleting headers and footers | New Users | |||
Change paper size; Word changes to invalid margins | New Users | |||
In Word, how can I see all files (*.*) in "save as"? | New Users |