odd Command Button behavior (dead spot)

ildenizen

New Member
Joined
Dec 19, 2007
Messages
9
I have a vba macro with the following structure:
- Open a Form A (vbModeless)
- In form, I have tons of controls. Two of them are command buttons.
- When I click on button 1 - another form (B) is displayed. This one is Modal.
- When I click on button 2 - another form (C) is displayed. This one is also Modal.

So my issue is that Forms A and B behave admirably.
But for some reason, Form C is brought up only sometimes when I process the click event on Button 2.

As I have played around with this, it is as if the when I click on parts of the button, I get a consisten response, but when I click on the top right quadrant (appoximately), nothing.

This should be really simple... and is driving me crazy.

Button is coded like this:

Private Sub CommandButton2_Click()
UserformC.Show
End Sub

I am not sure where to even start looking. I have put a break in the click event, and can confirm that I do not enter it each time I click on the button in question. When I do, my form is displayed just fine.

My only thought is that maybe there is some issue with having 2 modal forms? Long shot....

Any and all suggestions welcome :)
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Have you tried deleting the button and placing another??

I can never begin to think of erratic errors I prefer UHUHHH Fail
 
Upvote 0
Hi,
I can mimic your problem with code.
Open a new workbook and add a userform.
Add a CommandButton and a Label to the form.
It doesn't matter where you put the controls.

Double-click the form and insert this:

Code:
Private Sub UserForm_Initialize()
  With CommandButton1
    .Left = 84
    .Top = 48
    .Height = 36
    .Width = 48
  End With
  With Label1
    .Caption = ""
    .BackStyle = 0
    .BorderStyle = 0
    .Left = 114
    .Top = 36
    .Height = 30
    .Width = 40
  End With
End Sub
Private Sub CommandButton1_Click()
  UserForm1.Hide
End Sub

Run the form and click the upper right hand corner of the button and nothing happens.
Click elsewhere on the button and the form gets hidden.

Add this code to the form module:

Code:
Private Sub Label1_Click()
  MsgBox "You clicked on Label1"
End Sub

Click the upper right hand corner of the button.
There's a label there but you just can't see it.

You said the form has tons of controls on it.
My point is you might have a control on the form that has its BackStyle property set to
fmBackSyleTransparent and it is overlapping the button.
 
Upvote 0
Hi,
You said the form has tons of controls on it.
My point is you might have a control on the form that has its BackStyle property set to
fmBackSyleTransparent and it is overlapping the button.

That... i like, even if that ain't the fix in this case, im going to have to check that out on the form I have... if i can just remember which workbook it was lol. Ta.
 
Upvote 0
Lee , I just figured it out, and yes, you are correct. You win the prize ;)

Because I had so many controls, and most of them were dynamically created, it was hard to find out which one was the culprit.
I ended up adding a mousemove event handler for the offending button. I wrote out the X and Y to a screen, and plotted my responses.
Lo and behold, I could see the 2 shapes (labels with transparent background, and whose text was justified in such a way as to apprear to not be overlapping my control).

Once I knew the offending shape locations, I found my 2 labels, adjusted them, and the problem is now gone.

Thank you so much for your reply.
 
Upvote 0
Hi idenizen,

Thanks for the feedback and congrats on working out the solution on your own. I'm willing to
split the prize with you. Have a nice day.

And aside to Shadow123:
Hope you find yor workbook!

LEE355
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,399
Latest member
alchavar

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