Incorrect selection of listbox item on underlying userform.

HighAndWilder

Active Member
Joined
Nov 4, 2006
Messages
376
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

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
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,213,501
Messages
6,114,010
Members
448,543
Latest member
MartinLarkin

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