0

I am using a MS Access application in local network, this application have form for display data, and one of the features in the form is opening picture files regarding the data in the form. My issue is opening the pictures are very slow for the Front End users (1 to 5 seconds). This is my function for the opening photos:

Public Sub OpenPicture(PictureName As Variant)
    If PictureName <> "" Then
        DoCmd.SetWarnings False            
        Dim iPath , filePath As String
        iPath = "C:\photo\"
        filePath = iPath & PictureName 
        Application.FollowHyperlink filePath
        DoCmd.Requery
        DoCmd.SetWarnings True
    End If
End Sub

In the above code, PictureName is the name of the image in the DataForm. I should mention there are Image controls for showing pictures in the DataForm, but these controls are small. My purpose is to crop or rotate these pictures in case of need in other programs.
Also I have a lot of image files (more than 200000) in the image source folder. Please help me for improving the speed of this function. Thanks in advance.

Mohammad
  • 13
  • 5
  • If your code works but just runs slow, then this question is better suited for Code Review – dwirony Mar 12 '18 at 18:55
  • Typo or error, extra parenthesis: `If (PictureName <> "" Then`. – wazz Mar 12 '18 at 23:37
  • filePath is not defined. – wazz Mar 12 '18 at 23:43
  • Do you really need to open image with another program? Consider using an Image control on a form or report to view images. Path/filename can be constructed in ControlSource property. Probably won't even need VBA. – June7 Mar 13 '18 at 00:28
  • Thanks to all for your comments. I corrected my question. Actually I need to open image for editing like rotating and cropping. Also in the DataForm I have ten fields for name of the pictures. – Mohammad Mar 13 '18 at 02:59
  • You can try other methods of opening the file, see: https://stackoverflow.com/a/40462913/3820271 -- *`Application.FollowHyperlink` is fickle.* – Andre Mar 13 '18 at 10:33

0 Answers0