Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Leesa Leesa is offline
external usenet poster
 
Posts: 5
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey Greg Maxey is offline
external usenet poster
 
Posts: 285
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Leesa Leesa is offline
external usenet poster
 
Posts: 5
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey Greg Maxey is offline
external usenet poster
 
Posts: 285
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Leesa Leesa is offline
external usenet poster
 
Posts: 5
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Leesa Leesa is offline
external usenet poster
 
Posts: 5
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Word should catalog misspelled words to study. rndthought Microsoft Word Help 39 May 21st 23 02:47 AM
How to put graphics on envelopes? Steve Koenig Microsoft Word Help 21 April 29th 23 02:47 AM
I am having difficulty with deleting headers and footers LHD New Users 5 July 24th 06 01:44 AM
Change paper size; Word changes to invalid margins OhioTech New Users 10 July 6th 06 02:00 PM
In Word, how can I see all files (*.*) in "save as"? citizen53 New Users 8 April 4th 05 04:56 PM


All times are GMT +1. The time now is 07:58 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"