How to properly create an event associated with a label

zestygirl

Registered User.
Local time
Today, 17:55
Joined
Jan 28, 2005
Messages
33
I am trying to apply the following behaviour to a label formatted as a Raised Label (Label1) in order to make it mimic a button:

I have a label with the 'on click' macro set to exit the form.

I want to create a bit of code as follows:

On Mouse Down:
- I click event the button to choose the code builder and I see this:

Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

End Sub


- I begin typing as follows (red):

Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

[Label1].SpecialEffect = 2
End Sub


I do the same thing for "On Mouse Up" but insert SpecialEffect "1" (to mimic the clicking behaviour you get with a button).

Then I close the code builder.

When I open the form and click the button, nothing happens. It just exits the form as have specified but does not 'move'. It's like the code I put in is not working.

Am I doing something wrong? Can someone help me? Composing code is not something I am familiar with so I suspect I may have made a mistake.
 
If the point of the label is to exit the form, what possible difference could it make if the label acts like a command button? In point of fact, I suspect that your code is, in fact, executing, but doing the formatting so quickly, in conjunction with closing the form, that it is not visible to the human eye!

Linq ;0)>
 
I thought of this too.... I took away the exit behaviour just to try to make the button 'click'....

I guess my question is this:

How the heck do you apply a specialeffect property to a label?? lol...I cannot seem to manage it via macros, expressions or code.....!! I know I want to format as SpecialEffect = 2 on mousedown and SpecialEffect = 1 on mouse up.
 
It works for me. I just tested with a form (Access 2003 SP3) and a label and have:

Code:
Private Sub Label11_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Me.Label11.SpecialEffect = 2
End Sub
 
Private Sub Label11_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Me.Label11.SpecialEffect = 1
End Sub

and it works just like you want it to. What version of Access are you using?
 
I just tried again....

using access 2007.

Thanks for replying....still baffled tho.
 
I just tried again....

using access 2007.

Thanks for replying....still baffled tho.

You do have code enabled don't you (database in a trusted location)? Also, you might verify that it is firing by putting a Debug.Print "MouseDown" and Debug.Print "Mouse Up" in the respective events and then see if anything appears in the VBA Immediate Window when you click it.

One other thing that might be of use - there is a place (can't remember exactly where at the moment but it is under Access Options) where you can select to use Windows Themed Controls or not. That being checked might be part of the problem.
 
Gosh!! How silly of me. Yes, I have enabled macros and code....works fine now.

Didn't even consider that - I errounously left it disabled when I opened the database.

Thanks, Bob.
:)
 

Users who are viewing this thread

Back
Top Bottom