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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hyperlink Picture in a Report - Problem

Status
Not open for further replies.

BakerUSMC

Technical User
May 24, 2003
96
US
Hello to all,

I am using an image control on a report to show a picture through a hyperlink based off of 2 fields. I can get the picture to show with now problem. But if there is no file name in Me!Photo, the report uses the picture from the previous record.

I am trying to use the following code on the OnFormat Event of the report:

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

    If (IsNull(Me!Photo)) Then
    Me![Image].Properties("Picture") = ""

    Else
    
        Dim strFilePath As String
        strFilePath = DFirst("Location", "tblLocation") & Me!Photo
        
        If Dir$(strFilePath) <> "" Then
        'It exists
        Me![Image].Properties("Picture") = DFirst("Location", "tblLocation") & Me!Photo

        Else
        'It don't.
        Me![Image].Properties("Picture") = ""

        End If
        
        
    End If

End Sub

Image = Image Control
Me!Photo = File name
DFirst("Location", "tblLocation") = File path location

Please tell me what's wrong with this code...because its not working!!! Thanks

BakerUSMC
 
Hello, I handled the problem this way.

In the reports query in included an Expression

PhotoExist: IIf(Len([photo])>5,1,2) 'Path

On the report a hidden text box - txtPhotoExist

And the report:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

Select Case Me.txtPhotoExist

Case 1

Me.imgPhoto.Picture = Me.txtPhoto
Me.imgPhoto.Visible = True

Case 2

Me.imgPhoto.Visible = False


End Select

I had the same problem clearing the picture so I set it to invisible where needed.

Hope that helps

 
dRahme,

Thanks for the reply...but have a question.

Where in the query do I put -

In the reports query in included an Expression

PhotoExist: IIf(Len([photo])>5,1,2) 'Path

Thanks
 
Just copy it into a blank field in your report's query. [Photo] is the field I use for the photo path.

Looks like yours is [location] so, PhotoExist: IIf(Len([location])>5,1,2)

I am looking for fields where the length of the string contained is > 5 (just an arbitrary number). If it is, I am assuming there is a path and Photo Exist = 1. If not, a 2.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top