Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Main Form - copy exact data from multiple worksheets with live lin uncreative Excel Worksheet Functions 1 March 17th 10 01:43 AM
Drop-down list on simple excel 2003 form using "form" from data me S Beals Excel Discussion (Misc queries) 0 March 2nd 10 08:35 PM
Adding items to a combo box on a user form Gazz_85[_2_] Excel Discussion (Misc queries) 1 July 9th 09 05:00 PM
How to pick one or more items out of a list, moving to new list, moving up or down. (form) Subteam Excel Discussion (Misc queries) 3 February 17th 06 04:13 AM
order form with multiple items and sizes for items Bernard56 Excel Discussion (Misc queries) 1 January 17th 06 11:43 PM


All times are GMT +1. The time now is 06:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"