![]() |
2nd Form deselects list box items on main form
I have a user form with a multi select list box. One of my functions selects
list items recommended for the user. I then put up a second form with the selected count, but when the 2nd form is hide or unload, selected items on the first form get unselected. It works with a msgbox, but I would rather use the 2nd form because I use mouse move to hide the form, and that I think is neat. What causes the listbox items to loose their selected status? Thanks. |
2nd Form deselects list box items on main form
show the code where you show the second form and the code where you hide the
second form and show the first form again. -- Regards, Tom Ogilvy "RandyDtg1" wrote in message ... I have a user form with a multi select list box. One of my functions selects list items recommended for the user. I then put up a second form with the selected count, but when the 2nd form is hide or unload, selected items on the first form get unselected. It works with a msgbox, but I would rather use the 2nd form because I use mouse move to hide the form, and that I think is neat. What causes the listbox items to loose their selected status? Thanks. |
2nd Form deselects list box items on main form
First form is never unloaded or hidden
Note below, if I use the Msgbox, the boxes stay selected on the first form. 'Code in first form code module Private Sub cmdFind_Click() Response = InputBox("Enter text to find:", Title, FindText) If Response = "" Then Exit Sub FindText = Response: Cntr = Zero For I = 0 To frmrwGetter.lstrGetter.ListCount - 1 temp = lstrGetter.List(I) ' gives Value J = InStr(One, temp, "@", vbTextCompare) If J Zero Then temp = Left(temp, J - One) J = InStr(One, temp, FindText, vbTextCompare) If J Zero Then lstrGetter.Selected(I) = True Cntr = Cntr + One End If Next I ' MsgBox Cntr & " found.", vbInformation, Title Load frmFound frmFound.lblFound.Caption = Cntr & " Found." frmFound.Show End Sub 'Code in second form code module Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) frmFound.Hide End Sub |
2nd Form deselects list box items on main form
It worked OK for me. However, it is possible that the form doesn't get
updated, so put in a doevents and possibly a repaint Private Sub cmdFind_Click() Response = InputBox("Enter text to find:", Title, FindText) If Response = "" Then Exit Sub FindText = Response: Cntr = Zero For I = 0 To frmrwGetter.lstrGetter.ListCount - 1 temp = lstrGetter.List(I) ' gives Value J = InStr(One, temp, "@", vbTextCompare) If J Zero Then temp = Left(temp, J - One) J = InStr(One, temp, FindText, vbTextCompare) If J Zero Then lstrGetter.Selected(I) = True Cntr = Cntr + One End If Next I Me.Repaint '<== added line DoEvents '<== added line ' MsgBox Cntr & " found.", vbInformation, Title Load frmFound frmFound.lblFound.Caption = Cntr & " Found." frmFound.Show End Sub -- Regards, Tom Ogilvy "RandyDtg1" wrote in message ... First form is never unloaded or hidden Note below, if I use the Msgbox, the boxes stay selected on the first form. 'Code in first form code module Private Sub cmdFind_Click() Response = InputBox("Enter text to find:", Title, FindText) If Response = "" Then Exit Sub FindText = Response: Cntr = Zero For I = 0 To frmrwGetter.lstrGetter.ListCount - 1 temp = lstrGetter.List(I) ' gives Value J = InStr(One, temp, "@", vbTextCompare) If J Zero Then temp = Left(temp, J - One) J = InStr(One, temp, FindText, vbTextCompare) If J Zero Then lstrGetter.Selected(I) = True Cntr = Cntr + One End If Next I ' MsgBox Cntr & " found.", vbInformation, Title Load frmFound frmFound.lblFound.Caption = Cntr & " Found." frmFound.Show End Sub 'Code in second form code module Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) frmFound.Hide End Sub |
All times are GMT +1. The time now is 11:48 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com