listbox

referee

Registered User.
Local time
Today, 00:51
Joined
Aug 21, 2003
Messages
38
Hello,

On a form I have a listbox with in this names of persons
if I seleKted a name in that listbox the name put in a textbox that's no problem but now I want that the name which I selekted no longer prevent in my listbox
if a then selected another name the previous name must again in the listbox etc...
can someone help me please with this code

thanks
 
There are two solutions RowSourceType depended.
1. Values:
Code:
Private Sub lbxListBox_DblClick(Cancel As Integer)
    Dim sSel As String
    
    If Nz(Me.lbxListBox) = "" Then Exit Sub
    sSel = Me.lbxListBox
    
    Me.lbxListBox.RowSource = Replace(Me.lbxListBox.RowSource, sSel & ";", "")
    Me.lbxListBox.RowSource = Replace(Me.lbxListBox.RowSource, sSel, "")
    
    If Nz(Me.txtTextBox) <> "" Then
        If Me.lbxListBox.RowSource = "" Then
            Me.lbxListBox.RowSource = Me.txtTextBox
        Else
            Me.lbxListBox.RowSource = Me.lbxListBox.RowSource & ";" & Me.txtTextBox
        End If
    End If
    
    Me.txtTextBox = sSel
    Me.lbxListBox.Requery
End Sub

2. Recordset:
Code:
Private Sub lbxListBox_DblClick(Cancel As Integer)
    Dim sSel As String
    
    If Nz(Me.lbxListBox) = "" Then Exit Sub
    sSel = Me.lbxListBox
    
    Me.lbxListBox.RowSource = "SELECT CompanyName FROM Suppliers " & _
                        " WHERE CompanyName<>""" & sSel & """"
    
    Me.txtTextBox = sSel
    Me.lbxListBox.Requery
End Sub
 
thanks for your answer
this is what i being searching for

thx
 

Users who are viewing this thread

Back
Top Bottom