Incorrect selection of listbox item on underlying userform.

HighAndWilder

Well-known Member
Joined
Nov 4, 2006
Messages
712
Office Version
  1. 365
Platform
  1. Windows
Hi All

I have a form 'frmRiders' which has a Command Button to load another form, 'frmSelectClub' from which one can select the club, using a listbox, to which the rider belongs.

The name of the club and the club id are each written to text boxes on the 'frmRiders' form and the 'frmSelectClub' form is hidden prior to it being unloaded when control passes
back to the 'frmRiders' form.

The 'frmSelectClub' sits on top of the 'frmRiders' form and when one selects a club, an item from a listbox directly underneath on the 'frmRiders' form is selected and the event code executed.

Has anybody come across this before and what is the cure / workaround, if any?

Cheers
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Are any of the controls on the two forms linked in any way?
 
Upvote 0
Not linked at all but this only happens when the selected item in the listbox on the 'frmSelectClub' is directly over one of the items in the listbox on the 'frmRiders' form. If the items do not appear to overlap then this does not happen.
 
Upvote 0
I have created a stand alone example of this problem.

https://www.dropbox.com/s/27h4bddlngpleqy/DropboxForms.xlsm?dl=0

Please open the form 'frmRiders' and click on the 'Club' button to select a club from the 'frmSelectClub' form.

You will notice that the rider selected on the Riders form changes dependant on where the clubs form is positioned and on which club you select.

I cannot imagine that I am the first person that this has happened to.

Any help appreciated.

Thanks
 
Upvote 0
Try changing the "Unload Me" to "Hide" as below.

Code:
Private Sub lstClubs_Click()
Dim strMsg As String
If fncIsFormLoaded("frmRiders") Then
     frmRiders!txtClub = Me.lstClubs
   [COLOR="#FF0000"] frmSelectClub.Hide 
[/COLOR]     If Me.chkShowMessage Then
          strMsg = "fvxfcgf"
          MsgBox strMsg, vbInformation, "Information"
     End If
End If
End Sub
 
Upvote 0
Try changing the "Unload Me" to "Hide" as below.

Code:
Private Sub lstClubs_Click()
Dim strMsg As String
If fncIsFormLoaded("frmRiders") Then
     frmRiders!txtClub = Me.lstClubs
   [COLOR="#FF0000"] frmSelectClub.Hide 
[/COLOR]     If Me.chkShowMessage Then
          strMsg = "fvxfcgf"
          MsgBox strMsg, vbInformation, "Information"
     End If
End If
End Sub


That change is not making any difference.

Do you see what the problem is MickG?

Does the change that you have suggested make a difference to how your copy works?

Cheers
 
Upvote 0
Yes, I See the problem.
I had a problem to find the cause because it did not occur when I stepped through the code, so I recreated the code in a simple format and found the "Unload Me" caused the problem. After removing it and replacing with "frmSelectClub.Hide"
the problem on both codes disappeared.
I've just retested this morning with "Unload Me" and the problem returned !!!

I don't know what else to say, I'm sorry I can't be more helpful !!!
 
Upvote 0
Yes, I See the problem.
I had a problem to find the cause because it did not occur when I stepped through the code, so I recreated the code in a simple format and found the "Unload Me" caused the problem. After removing it and replacing with "frmSelectClub.Hide"
the problem on both codes disappeared.
I've just retested this morning with "Unload Me" and the problem returned !!!

I don't know what else to say, I'm sorry I can't be more helpful !!!


If I put a MsgBox as the last line in the cmdSelectClub_Click event procedure in the frmRiders module the problem is solved.

Another way is to position the frmSelectClub form away from the listbox on the frmRiders form and maybe implement some intelligence so that the user
cannot select a club if there is an overlap.

Neither is ideal but I must move on.

Thanks for taking the time MickG.
 
Upvote 0
This worked !!!
Open both userforms "VbModeless"

Then set 2nd userform of to left :-
Code:
Private Sub cmdSelectClub_Click()
       Application.ScreenUpdating = True
       frmSelectClub.Show vbModeless
      [COLOR="#FF0000"] frmSelectClub.Left = 50
[/COLOR]       Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top