VBA Photos

PatAccess

Registered User.
Local time
Today, 15:23
Joined
May 24, 2017
Messages
284
Hello Guys,
I have a Photo Summary report with 10 photos. Each image's data source is an invisible field with the photo path in another folder.

Everything worked fine until yesterday. I noticed some of the images show sometimes and other times when I run the report it's not there.

Here is the Code I have for each

Private Sub cmdAddPhoto1_Click()
Dim objPhoto As Object
Dim strfile As String
Dim strfolder As String
Dim varItem As Variant
Set objPhoto = Application.FileDialog(3)
objPhoto.allowMultiSelect = True
If objPhoto.Show Then
For Each varItem In objPhoto.SelectedItems
strfile = Dir(varItem)
strfolder = Left(varItem, Len(varItem) - Len(strfile))
MsgBox "Folder" & strfolder & vbCrLf & "File: " & strfile
PhotoSource1 = strfolder + strfile
Next
End If
Me.Refresh
Set objPhoto = Nothing
End Sub

Any idea what my problem is?

Thank you
 
Maybe you code runs to fast, try by putting in a DoEvents.
Code:
..
    strfolder = Left(varItem, Len(varItem) - Len(strfile))
    MsgBox "Folder" & strfolder & vbCrLf & "File: " & strfile
    PhotoSource1 = strfolder + strfile
[B][COLOR=Red]    DoEvents[/COLOR][/B]
    Next
..
 
Hi,

Which version of Access are you using? If 2010 or later, you could try simply setting the control source of the image control to the "invisible" field's name.

Just a thought...
 
Hello Guys,
The Image control source is already the invisible field in the report.


The code I placed about is in the form when I upload the images but in the report, the images seems to show when they want and I don't understand what is happening here
 

Users who are viewing this thread

Back
Top Bottom