Error en Userform, Error en El Evento Exit de un ListBox
publicado
Muy Buen Dia, agradesco su ayuda.
El problema es que tengo un UserForm con 40 ListBox, en los cuales con el evento Exit deben de ir Armando un "Where" que quiero usar para SQL, los primeros 20 ListBox lo hacen perfectamente, pero los Siguientes 20, no hace nada cuando se cumple el evento.
Estube revisando paso a paso y primero cierra el UserForm y al final se va al Exit del Listbox(21-40) correspondiente.
Este es el Codigo de ListBox1, que funciona bien.
Private Sub F_1__Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim F As New Collection
For i = 0 To F_1_.ListCount - 1
If F_1_.Selected(i) = True Then F.Add ("Base.A1 = '" & F_1_.List(i) & "'")
Next i
If F.Count <> 0 Then
If F.Count = 1 Then Where1 = " AND ( " & F(1) & ")"
If F.Count >= 2 Then
T = ""
For i = 2 To F.Count
T = T & " OR " & F(i)
Next i
Where1 = " AND ( " & F(1) & T & ")"
End If
If Where1 <> "" Then Where = Where & Where1
End If
If F.Count <> 0 Then
T = L_1_.Caption & ": "
T = T & Replace(Replace(F(1), "Base.A1 = '", ""), "'", "")
If F.Count >= 2 Then
For i = 2 To F.Count
T = T & ", " & Replace(Replace(F(i), "Base.A1 = '", ""), "'", "")
Next i
End If
If TextoArticulo = "" Then
TextoArticulo = "Filtros de Articulo= " & T
Else
TextoArticulo = TextoArticulo & "- " & T
End If
End If
End Sub[/CODE]
Este es el codigo del ListBox21, que ya no funciona.
[CODE]Private Sub F_21__Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim F As New Collection
For i = 0 To F_21_.ListCount - 1
If F_21_.Selected(i) = True Then F.Add ("Base.A21 = '" & F_21_.List(i) & "'")
Next i
If F.Count <> 0 Then
If F.Count = 1 Then Where1 = " AND ( " & F(1) & ")"
If F.Count >= 2 Then
T = ""
For i = 2 To F.Count
T = T & " OR " & F(i)
Next i
Where1 = " AND ( " & F(1) & T & ")"
End If
If Where1 <> "" Then Where = Where & Where1
End If
If F.Count <> 0 Then
T = L_21_.Caption & ": "
T = T & Replace(Replace(F(1), "Base.A21 = '", ""), "'", "")
If F.Count >= 2 Then
For i = 2 To F.Count
T = T & ", " & Replace(Replace(F(i), "Base.A21 = '", ""), "'", "")
Next i
End If
If TextoArticulo = "" Then
TextoArticulo = "Filtros de Articulo= " & T
Else
TextoArticulo = TextoArticulo & "- " & T
End If
End If
End Sub
[/CODE]
Saludos, espero me puedan ayudar, ya busque mucho y no encuentro el error.
Featured Replies
Archivado
Este tema está ahora archivado y está cerrado a más respuestas.
Muy Buen Dia, agradesco su ayuda.
El problema es que tengo un UserForm con 40 ListBox, en los cuales con el evento Exit deben de ir Armando un "Where" que quiero usar para SQL, los primeros 20 ListBox lo hacen perfectamente, pero los Siguientes 20, no hace nada cuando se cumple el evento.
Estube revisando paso a paso y primero cierra el UserForm y al final se va al Exit del Listbox(21-40) correspondiente.
Este es el Codigo de ListBox1, que funciona bien.
Este es el codigo del ListBox21, que ya no funciona.
Dim F As New Collection
For i = 0 To F_21_.ListCount - 1
If F_21_.Selected(i) = True Then F.Add ("Base.A21 = '" & F_21_.List(i) & "'")
Next i
If F.Count <> 0 Then
If F.Count = 1 Then Where1 = " AND ( " & F(1) & ")"
If F.Count >= 2 Then
T = ""
For i = 2 To F.Count
T = T & " OR " & F(i)
Next i
Where1 = " AND ( " & F(1) & T & ")"
End If
If Where1 <> "" Then Where = Where & Where1
End If
If F.Count <> 0 Then
T = L_21_.Caption & ": "
T = T & Replace(Replace(F(1), "Base.A21 = '", ""), "'", "")
If F.Count >= 2 Then
For i = 2 To F.Count
T = T & ", " & Replace(Replace(F(i), "Base.A21 = '", ""), "'", "")
Next i
End If
If TextoArticulo = "" Then
TextoArticulo = "Filtros de Articulo= " & T
Else
TextoArticulo = TextoArticulo & "- " & T
End If
End If
End Sub
[/CODE]
Saludos, espero me puedan ayudar, ya busque mucho y no encuentro el error.