PC Review


Reply
Thread Tools Rate Thread

Dependant ComboBox on a UserForm

 
 
Jock
Guest
Posts: n/a
 
      19th Mar 2010
I have been successful in getting CB2 to be dependant on the value selected
in CB1 but only with single word items. When I try to adapt the code to use
two or more word options from CB1, I get the debug window. I realise why this
is happening - not allowed spaces or illegal characters - so I have been
trying to use OFFSET to get around this but to no avail.
I am losing hair over this one...
So....how can I get a list of meaningful multi word options in CB1 upon
which CB2 options are dependant?

UserForm code (adapted from PM's code) :

Option Explicit

Private Sub UserForm_Initialize()
Dim cell As Range
For Each cell In Worksheets("claims").Range("ClType").Cells
ComboBox1.AddItem cell.Value
Next
ComboBox1.Text = " < Claim type > "
End Sub

Private Sub ComboBox1_Change()
populateCB2 ComboBox1.Value
End Sub

Sub populateCB2(WotClaim As String)
Dim cell As Range
If ComboBox1.ListIndex = -1 Then Exit Sub
ComboBox2.Clear

For Each cell In Worksheets("Claims").Range("val." & WotClaim).Cells
ComboBox2.AddItem cell.Value
Next
ComboBox2.Text = " < Claim value > "

End Sub

Thanks

--
Traa Dy Liooar

Jock
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      19th Mar 2010
Try this

Private Sub ComboBox1_Change()
populateCB2 Replace(ComboBox1.Value, " ", "")
End Sub


--

HTH

Bob

"Jock" <(E-Mail Removed)> wrote in message
news:A3FD16D6-75E6-45F0-B33C-(E-Mail Removed)...
>I have been successful in getting CB2 to be dependant on the value selected
> in CB1 but only with single word items. When I try to adapt the code to
> use
> two or more word options from CB1, I get the debug window. I realise why
> this
> is happening - not allowed spaces or illegal characters - so I have been
> trying to use OFFSET to get around this but to no avail.
> I am losing hair over this one...
> So....how can I get a list of meaningful multi word options in CB1 upon
> which CB2 options are dependant?
>
> UserForm code (adapted from PM's code) :
>
> Option Explicit
>
> Private Sub UserForm_Initialize()
> Dim cell As Range
> For Each cell In Worksheets("claims").Range("ClType").Cells
> ComboBox1.AddItem cell.Value
> Next
> ComboBox1.Text = " < Claim type > "
> End Sub
>
> Private Sub ComboBox1_Change()
> populateCB2 ComboBox1.Value
> End Sub
>
> Sub populateCB2(WotClaim As String)
> Dim cell As Range
> If ComboBox1.ListIndex = -1 Then Exit Sub
> ComboBox2.Clear
>
> For Each cell In Worksheets("Claims").Range("val." & WotClaim).Cells
> ComboBox2.AddItem cell.Value
> Next
> ComboBox2.Text = " < Claim value > "
>
> End Sub
>
> Thanks
>
> --
> Traa Dy Liooar
>
> Jock



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying 1 combo box dependant on details chosen in another combobox Deltic Microsoft Access Queries 1 30th May 2009 02:43 PM
Howto make Combobox requery based on dependant combobox values Shane Microsoft Access Form Coding 1 22nd Apr 2008 09:14 AM
Dependant Combobox not showing current value if record viewed =?Utf-8?B?UHVyZVJhZGlhbnRKb3k=?= Microsoft Access Form Coding 1 23rd Aug 2007 11:49 PM
dependant combobox list L Sholes Microsoft Excel New Users 1 10th Apr 2006 11:29 AM
Dependant Combobox MBlake Microsoft Excel Programming 4 28th Apr 2005 12:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:22 PM.