I want to load values from a lstview column to a combobox in another form.

The problem is that, my combobox style is 2 - Dropdown List and the values in it are from my database field. That's where the error occurs.

Saying Text property is read only. I could use the 0 - Dropdown combo style but users will be able to:

1. Write on it (fixed already using Keyascii = 0)
2. Enable users to copy paste. (by using the mouse)

I want to disable number 2 as well if you may.

I need help, any of the two may do..

Thanks.

Edited 5 Years Ago by abelingaw: n/a

If both the controls are using database as source then why you need to populate data from one control to another ?

I have to edit an employee record so i have to load his record displayed from a listview in another form where I will edit it.

So that the combobox vale would be the same value as the listview column from the previous form.

It does.

But i want to load the current record on the listview into a combobox on another form.

And i can't because that error appears, I don't want to change the combobox style to 1 or 0.

Abe, give me the code you are using for population of listview and combobox, the adding of data as well to the combo in form 2.

Populate listview:

Call Con("Database.mdb")
    
    lvlEmpInfo.ListItems.Clear
    
    With RecSet
        .Open "Select * from EmpRecord", DBLink, adOpenKeyset, adLockPessimistic

        Do While .EOF = False
    
            lvlEmpInfo.ListItems.Add , , .Fields("Trans_ID")
    
            For i = 1 To 13
                lvlEmpInfo.ListItems(lvlEmpInfo.ListItems.Count).SubItems(i) = .Fields(i)
            Next i

            .MoveNext
        Loop
    
        .Close
    End With
    
    DBLink.Close

Populate Combobox:

Set db = New ADODB.Connection
        db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0; Data Source=" & App.Path & "\Database.mdb"
    
Set rs = New ADODB.Recordset
        rs.Open "Select Post from Post", db, adOpenStatic, adLockOptimistic

Set cboPost.DataSource = rs


        'cbodept.DataField = "Office"
        Do Until rs.EOF
        
                cboPost.AddItem rs.Fields("Post")
            rs.MoveNext
        Loop

        rs.MoveFirst
        
        
        If rs.Fields("Post") = "Administrative Aide I" Then
            txtBasicRate.Text = "5000.00"
        End If
            

    rs.Close
db.Close

I have only one combo box sir, and its where i want to pass the values of the selected record from a column in the listview. Listview is first form and the combo box is on the second form.

When i load it via Edit command button, err appears saying the error i stated above.
As i said, i don't like changing the combobox style to 0 or 1.

If I understand this correctly, the following -

Do not use a recordset to populate the combo, use the listview.

Dim x As Integer

for x = 0 To lst.ListCount - 1
With form2
.Combo1.AddItem lst.Text
Next x

Edited 5 Years Ago by AndreRet: n/a

It does works sir but still get the error. Text is read only property It highlights here:

Form5.cboPost.Text = .SubItems(11)

I think its the text property since my combobox style is 2.

This question has already been answered. Start a new discussion instead.