Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2015
    Posts
    1

    Unanswered: Link a picture to form

    Hello,

    I have on my computer a folder with all the pictures of members.
    I have made a form with the personal information of each of them, I can not link the picture manually because their are too many.
    The members have a member number, the picture has the same number.( 1012.jpg )
    How can I visualize the picture in the form.
    ( access 2013 )

    Thanks

  2. #2
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    495
    Provided Answers: 24
    Scan the folder of photos , each photo name is the member id
    load the photo path, or actual photo into db.

    Code:
    '----------------
    Public Sub ScanAllFilesInDir()
    '----------------
    Dim fso, oFolder, oFile, vDir, vFile
    Dim vMemNum
    
    vDir = "Z:\Users\photos\"
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set oFolder = fso.GetFolder(vDir)
    
    For Each oFile In oFolder.Files
        vFile = vDir & oFile.Name
        If InStr(vFile, ".jpg") > 0 Then      'ONLY get JPG files
                          
               vMemNum = Left(oFile.Name, Len(oFile.Name) - 4)
               Me.Filter = "[MemberID]=" & vMemNum
               Me.FilterOn = True
               If txtMemberID= vMemNum Then
                    txtPhotoPath = vFile  'LOAD THE PATH TO THE PHOTO
            
                   ' Img.SourceDoc = (vFile)    'LOAD THE PHOTO to BOUND OLE OBJECT field
                   ' Img.Action = acOLECreateEmbed
               End If
               
        End If
    Next
    Set fso = Nothing
    Set oFile = Nothing
    Set oFolder = Nothing
    MsgBox "Done"
    End Sub

Posting Permissions

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