|
-
Feb 26th, 2013, 06:56 AM
#1
Thread Starter
Fanatic Member
Error - Text Property is read-only
Hi
Set rs = New ADODB.Recordset
If rs.State = 1 Then rs.Close
rs.Open "temp", cnn, adOpenDynamic, adLockOptimistic, adCmdTable
On the line
cmb1.Text = rs!name
it is giving error "Text property is read-only."
Thanks
-
Feb 26th, 2013, 07:06 AM
#2
Re: Error - Text Property is read-only
Is it a normal combobox ?
What style is it set to ?
My quick test was style = 0, and I could do this -
Private Sub Form_Click()
Combo1.Text = "Rob"
End Sub
And "Rob" appeared
Rob
And I hope you are not using binding (If I have told you once, I have told you a million times "do not use binding")
-
Feb 26th, 2013, 09:58 AM
#3
Re: Error - Text Property is read-only
If the style of the combo is drop down list then this can be an issue. I forget now if you can not set the text at all or if you can only set it to a member that is in the list already. No time to test it now but it is one or the other/ If you change the style you can modify the text or you can use the listindex property to change it.
-
Feb 26th, 2013, 10:30 AM
#4
Banned
Re: Error - Text Property is read-only
-
Feb 26th, 2013, 10:31 AM
#5
Member
Re: Error - Text Property is read-only
As DataMiser says, Dropdown combo's text can only be derived from the existing list by using the list index property.
Try this sub
Code:
Sub UpdateMyCombo(cmb as combobox, mytext as string)
dim i%
for i = 0 to cmb.listcount -1 'If its in the list already use it
If mytext = cmb.list(i) then
cmb.listindex = i
exit sub
end if
next i
cmb.additem mytext 'If not add it
cmb.listindex = cmb.listcount -1
end sub
-
Feb 26th, 2013, 10:39 AM
#6
Re: Error - Text Property is read-only
Or use sendmessage with cb_findfirst. A lot faster than looping through the list
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|