PC Review


Reply
Thread Tools Rate Thread

Command button stops working when code is added

 
 
0 1
Guest
Posts: n/a
 
      7th Jan 2011
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?
 
Reply With Quote
 
 
 
 
Damon Heron
Guest
Posts: n/a
 
      10th Jan 2011
Labels have a click event. Have you tried using that instead of transparent
command buttons?

Damon


"0 1" <(E-Mail Removed)> wrote in message
news:a44bcff1-e5d6-49ba-a7e7-(E-Mail Removed)...
> 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?


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command button filter stops working when put in a subform =?Utf-8?B?S2V2aW4=?= Microsoft Access Form Coding 2 16th Nov 2006 01:04 PM
Adding Code to Command Button Added At Run Time =?Utf-8?B?S2V2aW4gRS4=?= Microsoft Excel Programming 2 18th Oct 2006 04:11 PM
Create button code stops working Stuart Microsoft Excel Programming 5 1st May 2005 09:18 PM
Re: Command Button Code not working Van T. Dinh Microsoft Access VBA Modules 3 30th Aug 2004 10:08 PM
Command button code not working Paul Microsoft Access Form Coding 3 12th Aug 2004 03:25 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:49 PM.