اذهب الي المحتوي
أوفيسنا

أبحث عن فكرة أو طريقة ما للتراجع عن تسجيل قيمة عند الغاء التحديد من القائمة


إذهب إلى أفضل إجابة Solved by jjafferr,

الردود الموصى بها

السلام عليكم 

الموضوع باختصار أنه لدينا لست بوكس listBox يتم الاختيار منه لملأ مربع نص textBox والمطلوب عند التراجع عن الاختيار من الليست listBox كيف يمكن حذف القيمة من التكست textBox

أرجو أن تكون الفكرة واضحة 

وهنا مرفق 

 

TestList.rar

رابط هذا التعليق
شارك

  • أفضل إجابة

وعليكم السلام اخوي ابو عبدالله:smile:

 

ايش رايك بهذه الطريقة ، اختيار اعضاء الفريق ، هو الذي يقرر التشكيل ،

والكود يذكرك بالاعضاء المختارين ، كلما تختار الفريق:

693.gif.a20cb2236489f148b1f4dd661ec89116.gif

 

وهذا هو الكود:


Private Sub List0_AfterUpdate()
On Error GoTo err_List0_AfterUpdate

List2.RowSource = ""
List2.RowSource = "Select TypID,MemprName From MemprsTbl Where TypID=" & Me.List0.Column(0)

    'everytime we click in List0, we look in Text4 items,
    'every item in Text4, we select it in List2
    
    'now show the items selected before, and exist Text4 now
    Dim x() As String
    
    'split each line of Text4 based on vbCrLf
    x = Split(Nz(Me.Text4, ""), vbCrLf)
    'loop through all the lines
    For i = LBound(x) To UBound(x)
        
        For j = 0 To List2.ListCount - 1
            'now loop through List2
            
            strSelected = Me.List2.Column(1, j) & ";" & Me.List2.Column(0, j)
            If x(i) = strSelected Then
                'select List2 item if it is the same as Text4
                Me.List2.Selected(j) = True
            End If
    
        Next j
    Next i
    
Exit Sub
err_List0_AfterUpdate:

    If Err.Number = 94 Or Err.Number = 9 Then
        Resume Next
    Else
        MsgBox Err.Number & vbCrLf & Err.Description
    End If
    
End Sub

Private Sub List2_Click()
On Error GoTo err_List2_Click
    
    'everytime we click in List2, we look in Text4 items,
    'if there are Selected in List2, we leave it in Text4,
    'if there are Not Selected in List2, we remove them from Text4
    
    'loop through List2 items
    For i = 0 To List2.ListCount - 1
    
        strSelected = Me.List2.Column(1, i) & ";" & Me.List2.Column(0, i)
        If Me.List2.Selected(i) Then
            
            'is List2 item selected, add it to Text4
            'but is it there already
            If InStr(Nz(Me.Text4, ""), strSelected) = 0 Then
                Me.Text4 = Me.Text4 & strSelected & vbCrLf
            End If
        
        Else
        
            'Remove from Text4
            Me.Text4 = Replace(Me.Text4, strSelected & vbCrLf, "")
    
        End If
    
    Next i
    
Exit Sub
err_List2_Click:

    If Err.Number = 94 Then
        Resume Next
    Else
        MsgBox Err.Number & vbCrLf & Err.Description
    End If
    
End Sub

 

جعفر

693.TestList2.mdb.zip

  • Like 5
رابط هذا التعليق
شارك

جزاكم الله خيرا 

وزادكم فضلا وعلما

وبركة فى العمر والمال والأهل 

تم 

:fff::fff:

  • Like 1
رابط هذا التعليق
شارك

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • تصفح هذا الموضوع مؤخراً   0 اعضاء متواجدين الان

    • لايوجد اعضاء مسجلون يتصفحون هذه الصفحه
×
×
  • اضف...

Important Information