Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2007

Tip: Looking for answers? Try searching our database.

Nested If result based on combo box value

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Santa-D - 28 Nov 2007 01:43 GMT
I've been trying to figure out (with no luck) a way to return a string
value to a text box based on a result from a combo box.

To try and keep it simple:

If Combobox = Value.A then textbox.value = Result.A
If Combobox = Value.B then textbox.value = Result.B
If Combobox = Value.C then textbox.value = Result C

I tried to do a select case but i obviously had the syntax wrong.

Any assistance is kindly appreciated.
Greg Maxey - 28 Nov 2007 02:05 GMT
I am assuming that these are UserForm objects:

Private Sub ComboBox1_Change()
Me.TextBox1 = Me.ComboBox1
End Sub

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> I've been trying to figure out (with no luck) a way to return a string
> value to a text box based on a result from a combo box.
[quoted text clipped - 8 lines]
>
> Any assistance is kindly appreciated.
Doug Robbins - Word MVP - 28 Nov 2007 02:13 GMT
What type of combobox are we talking about?

For a Dropdown type FormField as used in a protected document, you would use

Dim str as String
With ActiveDocument
   With .FormFields("Dropdown1").DropDown
       str = .ListEntries(.Value).Name
   End With
   If str = A Then
       .FormFields("Text1").Result = ResultA
   ElseIf str = B Then
       .FormFields("Text1").Result = ResultB
   Else
       .FormFields("Text1").Result = ResultC
   End If
End With

For a combobox on a userform, simply

If Combobox1.Value = A Then
   TextBox1.Text = ResultA
ElseIF Combobox1.Value = B Then
   TextBox1.Text = ResultB
Else
   TextBox1.Text = ResultC
End If

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> I've been trying to figure out (with no luck) a way to return a string
> value to a text box based on a result from a combo box.
[quoted text clipped - 8 lines]
>
> Any assistance is kindly appreciated.
Santa-D - 29 Nov 2007 07:20 GMT
On Nov 28, 11:13 am, "Doug Robbins - Word MVP"
<d...@REMOVECAPSmvps.org> wrote:
> What type of combobox are we talking about?
>
[quoted text clipped - 46 lines]
>
> - Show quoted text -

Thanks Doug,

It's a formfield on a protected document and I've seen where I wa
Santa-D - 29 Nov 2007 07:22 GMT
On Nov 28, 11:13 am, "Doug Robbins - Word MVP"
<d...@REMOVECAPSmvps.org> wrote:
> What type of combobox are we talking about?
>
[quoted text clipped - 46 lines]
>
> - Show quoted text -

Thanks Doug,

It is a formfield in a protected document. I've seen where I went
wrong.  Thanks again for your help.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.