Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional Hyperlink In Report

Status
Not open for further replies.

curlydog

Technical User
Aug 18, 2004
14
GB
Hi,
I'm having trouble adding a hyperlink to a report. My underlying query has a field called LinkLive. If LinkLive has a value for a particular record in the report, I want the hyperlink to appear and work for the user ( The report will be exported as html). If linkLive has no value stored for that record then the hyperlink disappears. I have placed a textBox containing the linkLive value(invisible) on my report which I can use as a test.

I'm fairly happy that I have the correct programming logic, but I'm not happy with the events whch trigger my test. I've tried Detail.Format but this doesn't appear to fire. I've used debug.print in the Detail_Format routine as a test, but I never get any output.

I've used the Detail_Paint event, but I get inconsistent values associate with my hyperlinks. I've searched to try and find somewhere which explains Access reports events without any luck.
Here's the code I've been using, but using the Detail_paint event seems to fire it too often and I get these inconsistent hyperlinks (links where there shouldn't be and HyperlinkAddress which relates to another record).

Code:
    If IsNull(Me.tbLiveLink.Value) Then
        Debug.Print ("LiveLink is empty")
        Me.Label20.Caption = ""
        Me.Label20.HyperlinkAddress = ""
    Else
        Debug.Print ("LiveLink is NOT empty")
        Me.Label20.Caption = Me.tbLiveLink.Value
        Me.Label20.HyperlinkAddress = ""
        Me.Label20.HyperlinkAddress = Me.tbLiveLink.Value
        Me.Label20.FontUnderline = True
        Me.Label20.ForeColor = RGB(0, 0, 255)
        Me.Label20.FontBold = True
    End If
 
Oh. It runs as I switch from design to report view.
 
Right, I've sorted this out and will post this answer for the benfit of other beginners with a similar problem.

The problem appears to stem from how Access renders different views of the report. I want an event to fire each time a record from my query is rendered to the report. Hence I want to use an event associated with the "Detail" part of the report. If I switch from design to report view the Detail_Format is not fired and I think my code is not working.

If however, I switch from design to print preview view the Detail_format event is fired for every record in my report (just as I wanted it to do).

So the answer is simple. If you want to use an event that fires every time a record is written into the report, use Detail_Format, but make sure you switch to Print preview in order to test it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top