Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Text Read Only error

Posted on 2007-04-09
17
Medium Priority
?
152 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
  • 3
  • +1
17 Comments
 
LVL 9

Expert Comment

by:nito8300
ID: 18879521
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
ID: 18879545
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
ID: 18879553
Or you check the value before passing it

If r.value <> vbNull then
MyComboBox.Add(r.value)
end if
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:al4629740
ID: 18879583
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
ID: 18879601
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
ID: 18879609
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
ID: 18879616
can you post the code that triggers the error?

can we look at it?
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 18879622
List1.Text = ""

It it because you cannot assign value to the combobox that way...
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 18879624
I mean
List1.Text = ""

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

0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 18879631
List1.Text = ""

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


0
 

Author Comment

by:al4629740
ID: 18879641
Is there any way around this?
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 18879643
If you want to cleat the text you should better try this.


List1.listindex = -1
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 18879652
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 400 total points
ID: 18879655

Me.ComboBox1.SelText = ""
0
 

Author Comment

by:al4629740
ID: 18879760
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
ID: 18879799
If rec.Fields(0) = "" then
ComboBox1.listindex = -1
else
ComboBox1.text = rec.Fields(0)
end if
0
 
LVL 15

Accepted Solution

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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…
Suggested Courses

670 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