Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Main Form - copy exact data from multiple worksheets with live lin | Excel Worksheet Functions | |||
Drop-down list on simple excel 2003 form using "form" from data me | Excel Discussion (Misc queries) | |||
Adding items to a combo box on a user form | Excel Discussion (Misc queries) | |||
How to pick one or more items out of a list, moving to new list, moving up or down. (form) | Excel Discussion (Misc queries) | |||
order form with multiple items and sizes for items | Excel Discussion (Misc queries) |