Transfer Values Between Combobox and Listbox

bobby

Registered User.
Local time
Today, 03:04
Joined
Apr 29, 2004
Messages
28
AHH.. PLEASE help me ....

I really need some help.

I am designing a form that is interacting with some data in some tables.

I have a combo box, where a user selects what they want. Then the select another value from a combo box next to it. I want to add these two values to a listbox, one value in one column, and one value in another.

I have considered using a listview box, but when i type listview. in the vba program of access, there is no listitems option or add option.

Anyone PLEASE help me ?
 
In your form's Code Module, paste the following sub:
Code:
Private Sub AddItem(ctrl As Control, col1 As String, col2 As String)

    Dim strBuf As String
    strBuf = Nz(ctrl.RowSource, "")
    
    strBuf = strBuf & IIf(strBuf > "", ",", "") & col1 & "," & col2
    ctrl.RowSource = strBuf

End Sub

The listbox must have the RowSourceType set to Value List.

In the following example, you can call the AddItem function for a listbox control named MyList, to add the text values "Column One" and "Column Two" to Columns One and Two, respectively, thus:
Code:
Call AddItem(Me.MyList, "Column One", "Column Two")
 

Users who are viewing this thread

Back
Top Bottom