Command button stops working when code is added

0

0 1

I have several transparent command buttons on top of labels that, when
clicked, show/hide various forms. (Sort of a navigation menu of
sorts.)

The command buttons work fine, when the code is like this:

Private Sub cmdMenu1_Click()

Me.frmMenu1Stuff.Visible = True
Me.frmMenu2Stuff.Visible = False
etc.

End Sub

But the moment I start adding some code to reformat the labels (to
give a visual clue as to what menu the user clicked and is on), the
command buttons become disabled. For example:

Private Sub cmdMenu1_Click()

Me.frmMenu1.Visible = True
Me.frmMenu2.Visible = False
etc.

Me.lblMenu1.ForeColor = vbBlack
Me.lblMenu1.BackStyle = 1
Me.lblMenu2.ForeColor = vbWhite
Me.lblMenu2.BackStyle = 0
etc.

End Sub

After I add this code, cmdMenu1 works on the first click, but
thereafter it stops working, even after I close and reopen the
database. It "clicks" but doesn't execute any code - even a simple
MsgBox "Test" command I add to it. To troubleshoot, I've moved the
command buttons off to the side of the labels (in case the label was
moving to the front), made them not transparent (so I can that they
actually do get clicked), etc. - but the behavior is the same.

It's as if the formatting code I added somehow changes a property of
the command button, even though none of the code references it.

I'm completely stumped. I've also decompiled and compacted and
repair.

Any ideas?
 
D

Damon Heron

Labels have a click event. Have you tried using that instead of transparent
command buttons?

Damon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top