Results 1 to 3 of 3
  1. #1
    stepwaec is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2011
    Posts
    5

    Question Linked Picture Problem

    Need some help with the issue described below. Would be great to get some genius to have a look onto this.

    Case
    Employee Database
    Report that shows Employees with a linked picture

    Problem
    The Problem is that with the code I used below the picture for all employees are the same. As soon as I click on the report to a diffrent employee entry all pictures change to that employee.


    So instead of getting for every employee a diffrent picture I get the same picture for all employees depending on which entry I just clicked.

    Code
    Code:
    Private Sub Report_Current()
    'Linkes the Image in the Report to a specific Picture depending on the primary key (Personalnummer)
    Dim ximg, path, sFile
        path = "C:\Fotos\"
        ximg = Me![Personalnummer]
        sFile = path & ximg & ".jpg"
        If File_Exists(sFile) = True Then
    Me.Photo.Picture = path & ximg & ".jpg"
    Else
    Me.Photo.Picture = path & "placeholder.jpg"
    End If
    End Sub
    
    Private Function File_Exists(ByVal sPathName As String, Optional Directory As Boolean) As Boolean
    
    'Returns True if the passed sPathName exist
    'Otherwise returns False
    On Error Resume Next
    If sPathName <> "" Then
    
    If IsMissing(Directory) Or Directory = False Then
    
    File_Exists = (Dir$(sPathName) <> "")
    Else
    
    File_Exists = (Dir$(sPathName, vbDirectory) <> "")
    End If
    
    End If
    End Function

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    off the cuff; it appears that your code is up in the ReportCurrent area so it applies its changes to the entire report.

    you would need to put the code in the OnFormat area of the section where the image actually appears so the code only applies to the record that is getting formatted.

    Hope this helps.

  3. #3
    stepwaec is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2011
    Posts
    5
    Well turns out even with the changes u suggested that the problem still occurs. But I found out that the problem only occurs when I am opening the report in the normal view on access. As soon as as I go over to printpreview it is fine and every entry gets its picture.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Attachment Picture
    By cggriggs in forum Forms
    Replies: 0
    Last Post: 06-14-2011, 10:17 AM
  2. Picture - Problem W/ Edges of Form
    By anoob in forum Access
    Replies: 2
    Last Post: 01-13-2011, 01:49 AM
  3. Opening a picture
    By dada in forum Programming
    Replies: 1
    Last Post: 08-15-2010, 09:33 PM
  4. Adding a Picture
    By MFS in forum Programming
    Replies: 4
    Last Post: 01-18-2010, 07:19 AM
  5. Linked Table Manager Problem
    By tallerthantrees in forum Access
    Replies: 4
    Last Post: 08-17-2009, 03:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums