Solved

Text Read Only error

Posted on 2007-04-09
17
145 Views
Last Modified: 2010-04-30
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.
0
Comment
Question by:al4629740
  • 8
  • 5
  • 3
  • +1
17 Comments
 
LVL 9

Expert Comment

by:nito8300
Comment Utility
Why don't you hit a query instead of the table?

Select field1, field2
from your_query
where field1 NOT IS NULL
0
 

Author Comment

by:al4629740
Comment Utility
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
 
LVL 13

Expert Comment

by:Corey2
Comment Utility
Or you check the value before passing it

If r.value <> vbNull then
MyComboBox.Add(r.value)
end if
0
 

Author Comment

by:al4629740
Comment Utility
Maybe I didn't make the question clear enough.  I have a problem with assigning values to a read only combobox.  
0
 
LVL 13

Expert Comment

by:Corey2
Comment Utility
IIRC in a 2 drop down list style you have to supply a whole list you cannot add individual items.
0
 

Author Comment

by:al4629740
Comment Utility
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
 
LVL 15

Expert Comment

by:JackOfPH
Comment Utility
can you post the code that triggers the error?

can we look at it?
0
 
LVL 15

Expert Comment

by:JackOfPH
Comment Utility
List1.Text = ""

It it because you cannot assign value to the combobox that way...
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 15

Expert Comment

by:JackOfPH
Comment Utility
I mean
List1.Text = ""

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

0
 
LVL 15

Expert Comment

by:JackOfPH
Comment Utility
List1.Text = ""

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


0
 

Author Comment

by:al4629740
Comment Utility
Is there any way around this?
0
 
LVL 15

Expert Comment

by:JackOfPH
Comment Utility
If you want to cleat the text you should better try this.


List1.listindex = -1
0
 
LVL 15

Expert Comment

by:JackOfPH
Comment Utility
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
 
LVL 13

Assisted Solution

by:Corey2
Corey2 earned 100 total points
Comment Utility

Me.ComboBox1.SelText = ""
0
 

Author Comment

by:al4629740
Comment Utility
How about if it is

ComboBox1.Text =rec.Fields(0) from a database.  Thats what I really need to figure out.
0
 
LVL 15

Expert Comment

by:JackOfPH
Comment Utility
If rec.Fields(0) = "" then
ComboBox1.listindex = -1
else
ComboBox1.text = rec.Fields(0)
end if
0
 
LVL 15

Accepted Solution

by:
JackOfPH earned 400 total points
Comment Utility
or this
If rec.Fields(0).value = "" then
ComboBox1.listindex = -1
else
ComboBox1.text = rec.Fields(0).value
end if
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now