Drop Down List - "Other" Option

M

missujerr_junk

Hello, I have a form with a drop down box. The last option in the
drop down box is "Other". If someone selects that, I would like to
force them to type in what the "other" thing is. Is there a way to do
that?

Thanks a million,
Shell
 
H

Helmut Weber

Hi Shell,

like that:

Private Sub ListBox1_Click()
If ListBox1.ListIndex = ListBox1.ListCount - 1 Then
MsgBox "fill in textbox for other value"
TextBox1.SetFocus
End If
End Sub

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
M

missujerr_junk

Thanks a ton for the reply, but where do I go to enter that code?

Aprpeciate your help!
 
G

Gordon Bentley-Mix

Shell,

I believe what we have here is a classic case of "communication failure".
Helmut's response indicates to me that he believes you are asking about a
ComboBox control on a VBA UserForm - an understandable assumption since this
is the Word Programming forum. However, my reading of your initial post leads
me to believe that you are asking about a 'dropdown' type form field and not
a VBA ComboBox.

Unfortunately, I don't have an easy answer for you. In a VBA project, there
are many powerful tools for "forcing" a user to do something (although I
prefer to call it "implementing business rules" <g>). However, the options
available for use with form fields are much more limited.

You could try writing a macro to run 'On Exit' from the form field that does
something like prompt the user for the details of the "other" thing using an
InputBox, but that still won't *force* the user to enter something. The user
could just dismiss the InputBox and move on to the next form field.

You could also try something with an 'On Exit' macro for the 'Other
Description' form field that wouldn't allow the user to tab out of the field
until a value has been entered. (Said macro would, of course, check the value
of the dropdown first and run only if "Other" was selected.) However, the big
drawback with that solution is that the user will encounter difficulty if
they inadvertently selected "Other" and then wanted to change it; they would
have to enter something in the "Other Description" before they could get back
to the dropdown.

I'm sure there are other solutions but none spring immediately to mind.

Ultimately, the kind of control you're looking for is best accomplished
through the use of a VBA UserForm. In VBA you could look at the item selected
from the list in the ComboBox and enable or disable an "Other Description"
TextBox accordingly. You could also validate the values input / selected on
the click of a button and force the user to complete the required fields
before the document is created (or even disable the button completely if some
mandatory information is missing).

However, if you haven't done VBA programming previously - and your response
to Helmut's post leads me to believe you haven't - you may find this approach
beyond your current skill set. Should you choose to learn VBA, there are many
resources available to help you - the Word MVP site (http://www.mvps.org) and
this forum being among the best. It's not a quick process, but it's well
worth the effort if you want to go beyond what's available to you through the
"native" Word environment.

Alternatively, you could outsource the work. My rates are pretty reasonable
- especially if you're paying in USD... ;-D
--
Cheers!
Gordon
The Kiwi Koder

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 
M

missujerr_junk

Thanks very much Gordon, that is tremendously helpful and exactly
right. Since this is the only field on the form that I am needing to
modify, I will explore the macro suggestion. My apologies for posting
in the VBA forum, I did not intend to do that. I do program with VBA
in Access but have never done so in Word. Wish me luck with the macro,
because I only use those in Access and Excel but will figure out
something for Word (my least favorite program!).

Again, I appreciate your help!
Shell (who unfortunately is about out of dollars) :eek:)
 
G

Gordon Bentley-Mix

Shell,

Posting here turned out to be the right choice after all; it really was a
programming question in the end.

If you run into problems with your Word VBA macro let me know. I do a bit of
"pro bono" work (it generates good karma) and am always willing help poor,
deluded souls who actually enjoy Excel and Access programming. ;-D
--
Cheers!
Gordon

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top