Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Access VBA change an image on a different form

Hi. I have two forms. The first loads an image in the following event. The second has a button where the image can be edited. My problem
is that when I do this and go back to the first form the old image is there. I have tried to reload the image and refresh the form but it doesn't work

Private Sub Form_Current()
   Dim oDB_Folder As String: oDB_Folder = CurrentProject.Path
    Dim oSavedPath As String: oSavedPath = [PhotoFile]
    Dim oActualPath, F As String
    F = Replace(oSavedPath, "DatabaseFolder", oDB_Folder)
   Me.imgPhoto.Picture = F
End Sub

Open in new window

Private Sub btnSelectPhoto_Click()

    Dim strFile As String
    Dim PhotoFile As String
    strFile = GetFileName(CurrentProject.Path)
    If strFile > "" Then
        PhotoFile = Filenm(strFile)
        If Filepath(strFile) <> CurrentProject.Path & "\Media\ID Photos\" Then
            FileCopy strFile, CurrentProject.Path & "\Media\ID Photos\" & PhotoFile
        End If
        imgPhoto.Picture = CurrentProject.Path & "\Media\ID Photos\" & PhotoFile
        Me.PhotoFile = "DatabaseFolder" & "\Media\ID Photos\" & PhotoFile
        Form_f_LicenseeDetailsEdit.PhotoFile = "DatabaseFolder" & "\Media\ID Photos\" & PhotoFile
    End If
End Sub

Open in new window

Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

Probably something is missing
I think this
imgPhoto.Picture = CurrentProject.Path & "\Media\ID Photos\" & PhotoFile

Open in new window

should be
Form_Name_Of_Form_That_Holds_ThePhoto.imgPhoto.Picture = CurrentProject.Path & "\Media\ID Photos\" & PhotoFile

Open in new window

Form_MyForm.imgPhoto.Picture = CurrentProject.Path & "\Media\ID Photos\" & PhotoFile

Open in new window

Of course you can take a look at my Article and go the way of the BLOB :
Avatar of ste5an
Flag of Germany image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Murray Brown


Thanks for the help