Hi All,
I am using two listboxes to select items to be displayed on a report. I bring the form containing the two listboxes from the parent form's "Prudt" command button.
I use CR.Show and the list box form appears.
The navigation buttons such as add, remove etc work well initially. But after a while the Add and Rem events are not possible.It seems as if the listboxes need to be refreshed.But the AddAll and RemAll work well.
This does not happen when the form("Prudt") is initially opened.
..
Code
Private Sub cmdAdd_Click()
Dim iCtr As Long
Application.EnableEvents = False
Application.ScreenUpdating = False
If Me.lstBox1.ListIndex = -1 Then Exit Sub
For iCtr = 0 To Me.lstBox1.ListCount - 1
If Me.lstBox1.Selected(iCtr) = True Then
Me.lstBox2.AddItem Me.lstBox1.List(iCtr)
End If
Next iCtr
For iCtr = Me.lstBox1.ListCount - 1 To 0 Step -1
If Me.lstBox1.Selected(iCtr) = True Then
Me.lstBox1.RemoveItem iCtr
End If
Next iCtr
Application.EnableEvents = True
End Sub
Display More
Code
Private Sub cmdRem_Click()
Dim iCtr As Long
Application.EnableEvents = False
Application.ScreenUpdating = False
If Me.lstBox2.ListIndex = -1 Then Exit Sub
For iCtr = 0 To Me.lstBox2.ListCount - 1
If Me.lstBox2.Selected(iCtr) = True Then
Me.lstBox1.AddItem Me.lstBox2.List(iCtr)
End If
Next iCtr
For iCtr = Me.lstBox2.ListCount - 1 To 0 Step -1
If Me.lstBox2.Selected(iCtr) = True Then
Me.lstBox2.RemoveItem iCtr
End If
Next iCtr
Application.EnableEvents = True
End Sub
Display More
Is it a refresh issue or anything else? What's confusing is,the first time when the forms are open,all these navigations work.
Thanks
pragov