Results 1 to 6 of 6
  1. #1
    5 Star Lounger
    Join Date
    Oct 2001
    Location
    San Bernardino, California, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Text label behavior (XP,2000)

    Is there any way to make a text label appear to depress when clicked? I have some text labels (with color) that I am using for a main menu. I have given them the raised special effect and I will attach some code for the on click event. However, I would like for the label to appear sunken when it is clicked just before it executes the code. Is there a way to do this? basically I want to emulate a command button without using a command button due to color limitations.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Text label behavior (XP,2000)

    You can change the Special Effect property in the On Click code of the label:

    Private Sub MyLabel_Click()
    ' Make the label look depressed (sunken)
    Me.MyLabel.SpecialEffect = acEffectSunken
    ' Code to execute goes here
    ...
    ' The following line restores the label to look raised; omit if you want to keep it depressed.
    Me.MyLabel.SpecialEffect = acEffectRaised
    End Sub

    Note: if you restore the label to raised, you may not see the effect if you have a fast PC, depending on the amount of code to be executed.

  3. #3
    5 Star Lounger
    Join Date
    Oct 2001
    Location
    San Bernardino, California, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Text label behavior (XP,2000)

    thank you. You're right, with a fast PC you cannot see the effect. Is there anyway to insert a short delay - maybe 100 millisec between changing effect to sunken and executing code?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Text label behavior (XP,2000)

    You can use the form's On Timer event and TimerInterval properties for this:

    Private Sub MyLabel_Click()
    ' Sunken effect
    Me.MyLabel.SpecialEffect = acEffectSunken
    ' Turn timer ON
    Me.TimerInterval = 300
    ' Code to execute goes here
    ...
    End Sub

    Private Sub Form_Timer()
    ' Turn timer OFF
    Me.TimerInterval = 0
    ' Raised effect
    Me.MyLabel.SpecialEffect = acEffectRaised
    End Sub

  5. #5
    5 Star Lounger
    Join Date
    Oct 2001
    Location
    San Bernardino, California, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Text label behavior (XP,2000)

    Great! Would this also work if I had several labels on the same form? Wouldn't I need to distinguish them or could I treat them as a class (I'm not even sure what I just said)? Or, at least, collectively?

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Text label behavior (XP,2000)

    If you would want to have a "group" of buttons of which only one can be down at a time, by far the easiest way to do this is to create a group box with toggle buttons. Access will take care of depressing and releasing the buttons automatically, no code needed. Each of the toggle buttons has an option value, and the value of the group box as a whole is the option value of the toggle button that is down. Howver, just like with command buttons, you can't set the background (fill) color for a toggle button.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •