VBA command to not follow hyperlink

Montez659

Well-known Member
Joined
May 4, 2005
Messages
918
Weird title, but how else do you put it?

What I have is a label - lblMetricsReport - that has a hyperlink associated with it (in the hyperlink property box). The reason I have it like this is because when a user hovers, the arrow switches to hylperlink "hand" so they know they can click on it.

What I am doing is trying to check to see if a textbox is filled out with a date other than today. I have an if...then statement set up within VBA on lblMetricsReport_Click () to check the date. What I can't figure out, if it is possible, is the command to stop Access from following the hyperlink.

I understand that this is all possible to do completely through VBA without the hyperlink property, but for the label there is no On Hover to be able to switch the image to a hyperlink hand and to me that is failry important. But I am open to suggestions as to other ways to do this.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
In case anyone comes across this and needs to know a workaround, it is fairly simple. All i did was create an If...then statement in the On Click event of the control. In the if...then I set the hyperlink and sub-hyperlink properties to either blank or the correct path. I used this code below:
Code:
With Forms("Welcome - ADMIN").Controls("Label29").Hyperlink
        .Address = ""
        .SubAddress = ""
    End With
Else
    With Forms("Welcome - ADMIN").Controls("Label29").Hyperlink
        .Address = ""
        .SubAddress = "Report DNS_Metrics Reporting"
    End With
End If

Sometimes I scare myself.
 
Upvote 0
Why not use a button? Most people know that clicking one does something.

You could even add a tooltip if you want some sort of hover thing, though it might not be as pretty as the hyperlink one.

It could even be formatted so the caption of the button looks like a hyperlink.
 
Upvote 0
I originally had butons, but found that it looked a lot more organized with this particular interface as hyperlinks.
 
Upvote 0
The reason I was suggesting a button was because you sort of have more control over them.

Labels aren't usually meant to be used to actually do anything, I think that's kind of reflected in the no of events associated with them.

By the way, I'm not saying don't use labels - if they do what you want that's the most important thing.:)
 
Upvote 0
Norie, Thanks! You made me go back and look at buttons again and I see I can get the same effect by setting the background to transparent and also set the Cursor On Hover property. Works great!

I completely agree with your assesment of buttons, just didn't know that was what I was looking for.
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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