Results 1 to 6 of 6

Thread: Error - Text Property is read-only

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Posts
    688

    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

  2. #2
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,487

    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")

  3. #3
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    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.

  4. #4
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    Re: Error - Text Property is read-only



  5. #5
    Member
    Join Date
    Nov 2012
    Posts
    62

    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

  6. #6
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    5,263

    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
  •  



Click Here to Expand Forum to Full Width