Solved

Text Read Only error

Posted on 2007-04-09
17
151 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 100 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 400 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

Technology Partners: 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!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month6 days, 3 hours left to enroll

626 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