Multiple IF's with dropdown boxes

R

ray_johnson

In a protected form, I have a drop down box with "A" "B" and "C" as the
items. I want to have another field show "Apples" "Bananas" or "Cherries"
based on the selection from the drop down box.

I figure I need to use IF statements and nest them somehow, but I can't
figure it out for the life of me.

Can someone help?

Thanks
Ray
 
R

Robert_L_Ross

Have you thought about using the IF...Then...Else route? Or maybe a
Do...Until?

I'm having problems with the 2nd part of your question...do you know how to
assign the 2nd field to show "apples" or "Bananas"?

Maybe we can help each other figure this out.
 
R

Robert_L_Ross

I just found this and maybe it will work for you. If your box is actually a
drop down box, this worked on mine.

Sub SetToInformation()

Dim ATTNBox1 As String 'This is an ATTN box on a Fax Cover Sheet
Dim FaxNumber1 As String 'This is the Fax Number
Dim TelNumber1 As String 'This is the Telephone Number

Select Case _
ActiveDocument.FormFields("ToBox").DropDown.Value 'This is a drop down
Case 1
ATTNBox1 = "Blank Name"
FaxNumber1 = "(000) 000-0000"
TelNumber1 = "(000) 000-0000"
Case 2
ATTNBox1 = "Shar"
FaxNumber1 = "(800) 846-6444"
TelNumber1 = "(585) 248-7254"
Case 3
ATTNBox1 = "Rob's Cube"
FaxNumber1 = "(555) 555-5555"
TelNumber1 = "(555) 555-5555"
Case Else
' should never get here
ATTNBox1 = "Invalid Value"
FaxNumber1 = "(999) 999-9999"
TelNumber1 = "(999) 999-9999"
End Select
ActiveDocument.FormFields("ATTNBox").Result = ATTNBox1
ActiveDocument.FormFields("FaxNumber").Result = FaxNumber1
ActiveDocument.FormFields("TelNumber").Result = TelNumber1

End Sub

See if this works for you. The key is to make sure you keep the drop down
box ordered correctly...if you move one up or down, you need to adjust the
Case statements.

Rob
 

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