PC Review


Reply
Thread Tools Rate Thread

combobox.ListFillRangeTrouble in VBA

 
 
DogLover
Guest
Posts: n/a
 
      3rd Nov 2009
I am trying to use 2 different Listfill Ranges in a combo box depending on
whether a check box is true or false. The code blows up on the last line of
code ComboBoxDept.ListFillRange = NewFillRange. Can anyone help me figure
out what I'm doing wrong?


Dim NewFillRange As Range
If CheckBoxEntity.Value = True Then Set NewFillRange =
Worksheets("Demo").Range("DemoDeptByEntity")
If CheckBoxEntity.Value = False Then Set NewFillRange =
Worksheets("Demo").Range("DemoDept")
ComboBoxDept.ListFillRange = NewFillRange
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      3rd Nov 2009
Try it this way:

Dim NewFillRange As Range
If CheckBoxEntity.Value = True Then
Set NewFillRange = Worksheets("Demo").Range("DemoDeptByEntity")
Else
Set NewFillRange = Worksheets("Demo").Range("DemoDept")
End If
ComboBoxDept.ListFillRange = NewFillRange





"DogLover" <(E-Mail Removed)> wrote in message
news:19214DB2-A1B9-4F50-B39D-(E-Mail Removed)...
>I am trying to use 2 different Listfill Ranges in a combo box depending on
> whether a check box is true or false. The code blows up on the last line
> of
> code ComboBoxDept.ListFillRange = NewFillRange. Can anyone help me figure
> out what I'm doing wrong?
>
>
> Dim NewFillRange As Range
> If CheckBoxEntity.Value = True Then Set NewFillRange =
> Worksheets("Demo").Range("DemoDeptByEntity")
> If CheckBoxEntity.Value = False Then Set NewFillRange =
> Worksheets("Demo").Range("DemoDept")
> ComboBoxDept.ListFillRange = NewFillRange



 
Reply With Quote
 
FSt1
Guest
Posts: n/a
 
      3rd Nov 2009
hi
not sure but excel may think you are trying to assign the values of your
named ranges to the listfillrange. you may be getting a type mismatch error.
guessing.
try this......

ComboBoxDept.ListFillRange = NewFillRange.Address

regards
FSt1

"DogLover" wrote:

> I am trying to use 2 different Listfill Ranges in a combo box depending on
> whether a check box is true or false. The code blows up on the last line of
> code ComboBoxDept.ListFillRange = NewFillRange. Can anyone help me figure
> out what I'm doing wrong?
>
>
> Dim NewFillRange As Range
> If CheckBoxEntity.Value = True Then Set NewFillRange =
> Worksheets("Demo").Range("DemoDeptByEntity")
> If CheckBoxEntity.Value = False Then Set NewFillRange =
> Worksheets("Demo").Range("DemoDept")
> ComboBoxDept.ListFillRange = NewFillRange

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      3rd Nov 2009
I bet that checkboxentity is set to be checked or unchecked. (You're not using
triplestate = true).

Dim NewFillRange As Range
If me.CheckBoxEntity.Value = True Then
Set NewFillRange = Worksheets("Demo").Range("DemoDeptByEntity")
else 'it has to be false
Set NewFillRange = Worksheets("Demo").Range("DemoDept")
end if
me.ComboBoxDept.ListFillRange = NewFillRange.address(external:=true)





DogLover wrote:
>
> I am trying to use 2 different Listfill Ranges in a combo box depending on
> whether a check box is true or false. The code blows up on the last line of
> code ComboBoxDept.ListFillRange = NewFillRange. Can anyone help me figure
> out what I'm doing wrong?
>
> Dim NewFillRange As Range
> If CheckBoxEntity.Value = True Then Set NewFillRange =
> Worksheets("Demo").Range("DemoDeptByEntity")
> If CheckBoxEntity.Value = False Then Set NewFillRange =
> Worksheets("Demo").Range("DemoDept")
> ComboBoxDept.ListFillRange = NewFillRange


--

Dave Peterson
 
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
Access Problem: Combobox.setfocus fires combobox.OnClick event Hal Levy Microsoft Access Form Coding 5 31st Jul 2009 03:54 AM
Howto make Combobox requery based on dependant combobox values Shane Microsoft Access Form Coding 1 22nd Apr 2008 09:14 AM
delete fields in subform combobox after main form combobox is chan deb Microsoft Access 4 24th Jan 2008 10:09 PM
ComboBox.Items.Clear() causes the selection of Text inside the edit of the ComboBox Nomasnd Microsoft Dot NET Framework Forms 1 27th Sep 2006 06:32 PM
HowTo? shift focus in VBA IDE between Object combobox, procedure combobox, and Code window Malcolm Cook Microsoft Access 0 11th Oct 2005 03:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:46 AM.