Results 1 to 38 of 38

Thread: [RESOLVED] combo is text read only

  1. #1

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Resolved [RESOLVED] combo is text read only

    hey
    i got a error that say the combobox is read only (text)
    i solved this before but i forgot how
    i need the combobox to be on dropdownlist so no one can edit it.this is the number 2 in the options of the combobox

    tnx for the help

  2. #2
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,711

    Re: combo is text read only

    You can't change it while your program is running. Have to either work around it by adding a hidden combo box and switching them, or finding a 3rd party control.

  3. #3

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: combo is text read only

    ofcurse you can ive done this before but forgot how

  4. #4
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: combo is text read only

    When the combo style property is vbComboDropdownList, you can only change the text to one of the items in the list.

    a workaround can be adding an item that its text can changed only by you at run time.

    ex
    Code:
    Private Sub Form_Load()
        Combo1.AddItem 2
        Combo1.AddItem 3
        Combo1.AddItem 4
        Combo1.AddItem 5 ' the last item will be used as a variable item.
    End Sub
    
    Private Sub Command1_Click()
        Combo1.List(Combo1.ListCount - 1) = "6"
        Combo1.Text = "6"
    End Sub
    
    Private Sub Command2_Click()
        Combo1.List(Combo1.ListCount - 1) = "8"
        Combo1.Text = "8"
    End Sub



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

    Re: combo is text read only

    set combobox style to 2 also u can delete the combobox and add a replacment to remove the read only message
    Last edited by ladoo; Jun 23rd, 2013 at 01:04 AM.

  6. #6

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: combo is text read only

    Quote Originally Posted by ladoo View Post
    set combobox style to 2
    I did that thats wht i got the error

  7. #7

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: combo is text read only

    also u can delete the combobox and add a replacment to remove the read only message[/QUOTE]
    what do you mean replacement?

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

    Re: combo is text read only

    Quote Originally Posted by salsa31 View Post
    also u can delete the combobox and add a replacment to remove the read only message
    what do you mean replacement?[/QUOTE]



    in form1 it has combo1 = read only


    remove combo1 and re add combo1

  9. #9
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: combo is text read only

    The the "Locked" property of the combo box set to false? If not set it to "false".
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  10. #10

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: combo is text read only

    ladoo i dontunderstand
    Nightwalker its on false already
    i just want that the user will not be abled to change whats in the combobox thats it
    and for that i need it to work on Dropdownlist - 2

  11. #11
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: combo is text read only

    @salsa31

    DropdownList is used when the combo contains fixed items like week names, month names, etc...

    If it contains a list of items that changed according to the program state, just delete all items and re-populate with the new items, or consider my suggestion in the post #4.

    BTW: What is the kind of data that your combo contain?



  12. #12

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: combo is text read only

    i did some progress but still when i try to edit i get the same error..

    Code:
    Private Sub Form_Load()
    Dim cmb As Control
    For Each cmb In Me
    If TypeOf cmb Is ComboBox Then
    cmb.ListIndex = -1
    End If
    Next cmb
    
    Cmb1.Clear
    Cmb1.AddItem "1"
    Cmb1.AddItem "2"
    Cmb1.AddItem "3"
    Cmb1.AddItem "4"
        If NewRec Then
            Me.Caption = "new"
            BttnSave.Caption = "save"
         PickDate.Value = Now
         DTfinal.Value = Now
         
         
        Else
            BttnSave.Caption = "update"
            With FrmExpenses.LsVw.SelectedItem
                Me.Caption = "update for"
                PickDate.Value = Format(.Text, "dd/mm/yyyy")
                Txt(1).Text = .SubItems(1)
                Txt(2).Text = .SubItems(2)
                Txt(3).Text = .SubItems(3)
                Txt(4).Text = .SubItems(4)
                Cmb1.Text = .SubItems(5)
                Cmb2.Text = .SubItems(6)
                Cmb3.Text = .SubItems(7)
                DTfinal.Value = Format(.Text, "dd/mm/yyyy")
                
            End With
            ChkRepeat.Enabled = False
        End If
    End Sub

  13. #13

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: combo is text read only

    only in the update i get the error

    Code:
      Cmb1.text = .SubItems(5)
      Cmb2.text = .SubItems(6)
      Cmb3.text = .SubItems(7)

  14. #14
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: combo is text read only

    You may leave the combo style 0 (vbComboDropdown) and prevent the user editing it by this code
    Code:
    Private Sub Combo1_KeyPress(KeyAscii As Integer)
        KeyAscii = 0
    End Sub
    The user still able to change it by context menu (Paste), but i think there is code to disable the context menu.



  15. #15

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: combo is text read only

    tnk you its working now

  16. #16

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: [RESOLVED] combo is text read only

    can you tell me what they mean here?

    in a code example or something


    error message. To assign a default value to a combo box with the Style property set to 2, you need to set the ListIndex property of the combo box. If you assign a value to the Text property of a combo box with Style set to 0 (Dropdown Combo) or 1 (Simple Combo), you will not get the above error message.

  17. #17
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: [RESOLVED] combo is text read only

    Combo box with the Style property set to 2 cannot show anything not in its list, so you can use the Text property but only to show the text of an existing item.



  18. #18

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: [RESOLVED] combo is text read only

    i see
    ok tnx

  19. #19

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: [RESOLVED] combo is text read only

    4x2y your method did work but the problem is every time i press edit the text in the combobox moves 1 step to the left
    witch cuasing it to go off the line in the listview
    Attachment 101539

  20. #20
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: [RESOLVED] combo is text read only

    I don't see any combo in the screen shoot!

    Maybe the combo text starts with invisible characters e.g. spaces or tabs!



  21. #21

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: [RESOLVED] combo is text read only

    do you see the spaces in the listview?
    so what you suggesting?

    cmb1.additem "123" or

    to add to the right panel in the list option?

  22. #22
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: [RESOLVED] combo is text read only

    If the text starts with spaces use: cmb1.AddItem Trim$(text_to_add)
    If the text starts with tabs use: cmb1.AddItem Replace(Trim$(text_to_add), vbTab, vbNullString)



  23. #23

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: [RESOLVED] combo is text read only

    ok tnx for the help

  24. #24

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: [RESOLVED] combo is text read only

    still now working lol

  25. #25
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,176

    Re: [RESOLVED] combo is text read only

    Okay Salsa....am responding because of your Private Message....

    I did this:
    Started a new form.
    Put on a combobox (combo1)
    Changed combo1's Style to 2-Dropdown List
    Added a command button (command1)
    Populated combo1 with some test strings in form load (see code)
    Then I added a string using the click event of command1,
    and then set the text value of combo1 to that newly added string.

    No errors (no hits or runs either) :-)

    Code:
    Option Explicit
    
    Private Sub Command1_Click()
    Combo1.AddItem ("NEW TEST")
    Combo1.Text = "NEW TEST"
    End Sub
    
    Private Sub Form_Load()
    Dim x As Integer
    For x = 1 To 5
    Combo1.AddItem ("TEST" & CStr(x))
    Next x
    End Sub

  26. #26

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: [RESOLVED] combo is text read only

    i will try that but like i mentioned before i get this error only when i hit the update button

  27. #27
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,176

    Re: [RESOLVED] combo is text read only

    Understand....how about highlighting the line where the error occurs, and also snapshot and include the precise errror.....thx

  28. #28

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: [RESOLVED] combo is text read only

    ok i will do that right now

  29. #29

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: [RESOLVED] combo is text read only

    Attachment 101549Attachment 101551
    Code:
                Cmb1.text = .SubItems(5)
                Cmb2.text = .SubItems(6)
                CmbBank.text = .SubItems(7)



    Attachment 101553

  30. #30
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,176

    Re: [RESOLVED] combo is text read only

    Well, I think it's apples and oranges....it appears this error has nothing to do with the comboboxes, but rather the listview????


    I don't use listviews at all, so I would be remiss in attempting to help you solve this...but now that you have posted the highlighted line, and the error, I'd wager someone can assist. (Headed out now, but will check in the morning to see if it is resolved...if not, I can spend some time analyzing.)

    PS
    My reference earlier to "No Runs, No Hits, No Errors" is an AMERICAN thing....baseball. :-)

  31. #31

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: [RESOLVED] combo is text read only

    ok sam i wait for your response
    good day

  32. #32
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,176

    Re: [RESOLVED] combo is text read only

    Hmmm...I'm back, but you (or someone) must have edited post #29---I know longer see the code with the highlighted line in which the error exists. can you post the actual CODE you used (the entire sub or function) and re-post the line (highlight please) that caused the error.

  33. #33

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: [RESOLVED] combo is text read only

    hey sam this is the code and the error i get as soon as i change something in the combobox style -2

    this is update statment

    Code:
      BttnSave.Caption = "Update"
            With FrmExpenses.LsVw.SelectedItem
                Me.Caption = "Update Expenes for"
                PickDate.Value = Format(.text, "dd/mm/yyyy")
                Txt(1).text = .SubItems(1)
                Txt(2).text = .SubItems(2)
                Txt(3).text = .SubItems(3)
                Txt(4).text = .SubItems(4)
                Cmb1.text = .SubItems(5)
                Cmb2.text = .SubItems(6)
                CmbBank.text = .SubItems(7)
                DTfinal.Value = Format(.text, "dd/mm/yyyy")
                Txt(5).text = .SubItems(9)
    the error in subitems 5 , 6 , 7

    Code:
        Cmb1.text = .SubItems(5)
                Cmb2.text = .SubItems(6)
                CmbBank.text = .SubItems(7

  34. #34

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: [RESOLVED] combo is text read only

    and this is all the codes in the frmexpenses form
    Code:
    Option Explicit
    
    Private Sub Form_Load()
    
    Cmb1.AddItem "Mastercard"
    Cmb1.AddItem "Visa"
    Cmb1.AddItem "American Express"
    Cmb1.AddItem "Other"
       
       
       
       If NewRec Then
       
       
            Me.Caption = "New Expenes"
            BttnSave.Caption = "Save"
         PickDate.Value = Now
        Else
            BttnSave.Caption = "Update"
            With FrmExpenses.LsVw.SelectedItem
                Me.Caption = "Update for"
                PickDate.Value = Format(.text, "dd/mm/yyyy")
                Txt(1).text = .SubItems(1)
                Txt(2).text = .SubItems(2)
                Txt(3).text = .SubItems(3)
                Txt(4).text = .SubItems(4)
                Cmb1.text = .SubItems(5)
                Cmb2.text = .SubItems(6)
                CmbBank.text = .SubItems(7)
                DTfinal.Value = Format(.text, "dd/mm/yyyy")
                Txt(5).text = .SubItems(9)
                
            End With
            ChkRepeat.Enabled = False
        End If
    End Sub
    
    Private Sub BttnCancel_Click()
        Unload Me
    End Sub
    
    Private Sub BttnSave_Click()
     
        If Len(Trim$(Txt(1).text)) = 0 Then
            MsgBox "missing field"", vbInformation, ""
            Txt(1).SetFocus
            Exit Sub
        ElseIf Txt(2).text = 0 Then
            MsgBox "missing field" "0", vbInformation, ""
            Txt(2).SetFocus
            Exit Sub
        ElseIf Txt(3).text = 0 Then
            MsgBox "missing field", vbInformation, ""
            Txt(3).SetFocus
            Exit Sub
        End If
        
        If NewRec Then
            Dim NewID As Long
            NewID = NextID("ExpID", "Expenses")
            Dim strSQL As String
    strSQL = "INSERT INTO Expenses "
    strSQL = strSQL & "(ExpID, ExpDate, ExpType, ExpQuantity, ExpCost, ExpInvoice, ExpPament, ExpCredit, ExpBank, ExpFinal, ExpRemarks) "
    strSQL = strSQL & "VALUES("
    strSQL = strSQL & NewID & ","                           
    strSQL = strSQL & "#" & MyDate(PickDate.Value) & "#,"  
    strSQL = strSQL & "'" & RplS(Txt(1).text) & "',"        ''
    strSQL = strSQL & "'" & Txt(2).text & "',"             
    strSQL = strSQL & CCur(Txt(3).text) & ","               
    strSQL = strSQL & "'" & RplS(Txt(4).text) & "',"         
    strSQL = strSQL & "'" & Cmb1.text & "',"
    strSQL = strSQL & "'" & Cmb2.text & "',"
    strSQL = strSQL & "'" & CmbBank.text & "',"
    strSQL = strSQL & "#" & MyDate(DTfinal.Value) & "#,"
    strSQL = strSQL & "'" & Txt(5).text & "'"
    
    strSQL = strSQL & ")"
    
    
    
    CN.Execute strSQL
    
            Set Itm = FrmExpenses.LsVw.ListItems.Add(, , Format(PickDate.Value, "dd/mm/yyyy"), , "dolar")
            Itm.Tag = NewID
            Itm.SubItems(1) = Txt(1).text
            Itm.SubItems(2) = Replace$(Txt(2).text, ",", ".")
            Itm.SubItems(3) = Replace$(Txt(3).text, ",", ".")
            Itm.SubItems(4) = Replace$(Txt(4).text, ",", ".")
            Itm.SubItems(5) = Replace$(Cmb1.text, ",", ".")
            Itm.SubItems(6) = Replace$(Cmb2.text, ",", ".")
            Itm.SubItems(7) = Replace$(CmbBank.text, ",", ".")
            Itm.SubItems(8) = Replace$(DTfinal.Value, ",", ".")
            Itm.SubItems(9) = Replace$(Txt(5).text, ",", ".")
            
            If ChkRepeat.Value Then
                PickDate.Value = Now
                Txt(1).text = ""
                Txt(2).text = 1
                Txt(3).text = 0
                Txt(4).text = ""
                Cmb1.text = ""
                Cmb2.text = ""
                CmbBank.text = ""
                DTfinal.Value = Now
                Txt(5).text = ""
                
                ChkRepeat.Value = 0
                PickDate.SetFocus
                Exit Sub
            End If
        Else
            With FrmExpenses.LsVw.SelectedItem
             strSQL = "UPDATE Expenses SET "
    strSQL = strSQL & "ExpDate = #" & MyDate(PickDate.Value) & "#,"
    strSQL = strSQL & "ExpType = '" & RplS(Txt(1).text) & "',"
    strSQL = strSQL & "ExpQuantity = '" & Txt(2).text & "',"
    strSQL = strSQL & "ExpCost = " & CCur(Txt(3).text) & ","
    strSQL = strSQL & "ExpInvoice = '" & RplS(Txt(4).text) & "',"
    strSQL = strSQL & "ExpPament = ' " & Cmb1.text & "',"
    strSQL = strSQL & "ExpCredit = ' " & Cmb2.text & "',"
    strSQL = strSQL & "ExpBank = ' " & CmbBank.text & "',"
    strSQL = strSQL & "ExpFinal = #" & MyDate(DTfinal.Value) & "#,"
    strSQL = strSQL & "ExpRemarks = '" & Txt(5).text & "'"
    strSQL = strSQL & " WHERE ExpID = " & .Tag
    CN.Execute strSQL
                .text = Format(PickDate.Value, "dd/mm/yyyy")
                .SubItems(1) = Txt(1).text
                .SubItems(2) = Txt(2).text
                .SubItems(3) = Txt(3).text
                .SubItems(4) = Txt(4).text
                .SubItems(5) = Cmb1.text
                .SubItems(6) = Cmb2.text
                .SubItems(7) = CmbBank.text
                .text = Format(DTfinal.Value, "dd/mm/yyyy")
                .SubItems(9) = Txt(5).text
            End With
        End If
        Unload Me
        FrmExpenses.Loadentries
    End Sub

  35. #35
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,176

    Re: [RESOLVED] combo is text read only

    The problem is that you must ADD the item(s) to your comboboxes before you set the texts.

    so....try this:
    Cmb1.AddItem(.subitems(5))
    Cmb1.text = .SubItems(5)
    Cmb2.AddItem(.subitems(6))
    Cmb2.text = .SubItems(6)
    CmbBank.AddItem(.subitems(7))
    CmbBank.text = .SubItems(7)

  36. #36

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: [RESOLVED] combo is text read only

    where is the additem name

    cmb1.additem = "credit card"

    ?

  37. #37

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: [RESOLVED] combo is text read only

    tnkkkkkkkkk youuuuuuuuuuuuuuuuuuuuuu!!!!!!!!!!! its working finaly!!!!!!!!!

  38. #38

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: [RESOLVED] combo is text read only

    good day everyone
    Last edited by salsa31; Jun 25th, 2013 at 11:19 AM.

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