Results 1 to 5 of 5

Thread: [RESOLVED] text properties read only

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Resolved [RESOLVED] text properties read only

    What this error message mean?How to solve it?My combo box style is dropdownlist

    Combo1.Text = .Fields("Negeri").Value

  2. #2
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: text properties read only

    When comnbo is drop down list, it acts much like a list box. One way to around this to make sure the value you are assigning is already in the list.
    try something like this

    Code:
    Combo1.AddItem  .Fields("Negeri").Value
    Combo1.Text = .Fields("Negeri").Value
    But you may have to check whether item exists before you add it up
    IIF(Post.Rate > 0 , , )

  3. #3
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: text properties read only

    This is another approach. You capture the error and add it before setting text to the combo. But this way, you wont have duplicates in the combo box. If the text is there in the combo, the text will be set to it. Otherwise, its addded to the list and then Text is set.

    eg:
    Code:
    Option Explicit
    
    Private Sub Form_Load()
        Combo1.AddItem "Test1"
        Combo1.AddItem "Test2"
        Combo1.AddItem "Test3"
        Combo1.AddItem "Test4"
        
        
    End Sub
    
    Private Sub Text1_KeyPress(KeyAscii As Integer)
       On Error GoTo Text1_KeyPress_Error
    
        
        
        If KeyAscii = vbKeyReturn Then
            Combo1.Text = Text1.Text
        End If
        
        
    
    
       Exit Sub
    
    Text1_KeyPress_Error:
        If Err.Number = 383 Then
            If Len(Trim(Text1.Text)) > 0 Then
                Combo1.AddItem Text1.Text
                Combo1.Text = Text1.Text
            End If
        Else
            MsgBox "Error " & Err.Number & " (" & Err.Description & ") "
            
        End If
        
    End Sub
    You will need a Text Box(Text1) and Combo box(Combo1) to test this.
    Type something in the Text Box and press enter to work it out.



    EDIT: Changed code: Trim and Len switched
    Last edited by zeezee; Feb 2nd, 2008 at 10:37 AM.
    IIF(Post.Rate > 0 , , )

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: text properties read only

    Actually I want to update the record.

    The current record doen't have this value. So When I push edit button, I want to update the record by choose the value in the dropdownlist and insert this new value.

  5. #5
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: text properties read only

    Where do you want to update the record ? In DB or combo box?
    Anyway, the solution is for the error you have mentioned here. Try to change the code in Post #3 to suit your need. the Error handler part specially.

    IIF(Post.Rate > 0 , , )

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