Solved

Text Read Only error

Posted on 2007-04-09
17
146 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
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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

910 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

20 Experts available now in Live!

Get 1:1 Help Now