Text Read Only error

I have a ComboBox on my VB6 form and the Style is 2-Dropdown List.  When I get data from the database to the combobox I get an error.  It happens when a blank value (not null)  is retrieved and put into the ComboBox.  Is there any way to get around this error?  It is a Text Read only error.
al4629740Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nito8300Commented:
Why don't you hit a query instead of the table?

Select field1, field2
from your_query
where field1 NOT IS NULL
0
al4629740Author Commented:
The error occurs when I get a blank value and try to place it in a 2-Dropdown List Style.  That doesn't address how to get around the problem.
0
Corey ScheichDeveloperCommented:
Or you check the value before passing it

If r.value <> vbNull then
MyComboBox.Add(r.value)
end if
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

al4629740Author Commented:
Maybe I didn't make the question clear enough.  I have a problem with assigning values to a read only combobox.  
0
Corey ScheichDeveloperCommented:
IIRC in a 2 drop down list style you have to supply a whole list you cannot add individual items.
0
al4629740Author Commented:
I do the following

List1.Additem "" 
List1.Additem "1"
 List1.Additem "2"
List1.Additem "3"
List1.Text = "2"

and it works fine.  But if I try:

List1.Text = ""   I get a read only error
0
JackOfPHCommented:
can you post the code that triggers the error?

can we look at it?
0
JackOfPHCommented:
List1.Text = ""

It it because you cannot assign value to the combobox that way...
0
JackOfPHCommented:
I mean
List1.Text = ""

It is because you cannot assign value to the combobox that way...

0
JackOfPHCommented:
List1.Text = ""

The above line are used only for retrieving the currently selected item in the combobox.


0
al4629740Author Commented:
Is there any way around this?
0
JackOfPHCommented:
If you want to cleat the text you should better try this.


List1.listindex = -1
0
JackOfPHCommented:
I think you are trying to erase the selected text in the combobox, right?

To do this you should do this code:

List1.listindex = -1
0
Corey ScheichDeveloperCommented:

Me.ComboBox1.SelText = ""
0
al4629740Author Commented:
How about if it is

ComboBox1.Text =rec.Fields(0) from a database.  Thats what I really need to figure out.
0
JackOfPHCommented:
If rec.Fields(0) = "" then
ComboBox1.listindex = -1
else
ComboBox1.text = rec.Fields(0)
end if
0
JackOfPHCommented:
or this
If rec.Fields(0).value = "" then
ComboBox1.listindex = -1
else
ComboBox1.text = rec.Fields(0).value
end if
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.