From: Leesa on
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
From: Greg Maxey on
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" <Leesa(a)discussions.microsoft.com> wrote in message
news:DB7587D2-82E6-4FD4-9CA0-965F8753E58F(a)microsoft.com...
>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


From: Leesa on
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" <Leesa(a)discussions.microsoft.com> wrote in message
> news:DB7587D2-82E6-4FD4-9CA0-965F8753E58F(a)microsoft.com...
> >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
>
>
>
From: Greg Maxey on
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" <Leesa(a)discussions.microsoft.com> wrote in message
>> news:DB7587D2-82E6-4FD4-9CA0-965F8753E58F(a)microsoft.com...
>>> 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


From: Leesa on
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" <Leesa(a)discussions.microsoft.com> wrote in message
> >> news:DB7587D2-82E6-4FD4-9CA0-965F8753E58F(a)microsoft.com...
> >>> 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
>
>
>