Avatar of Murray Brown
Murray Brown
Flag 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
        Form_f_LicenseeDetailsEdit.Refresh
        Form_f_LicenseeDetailsEdit.Repaint
    End If
    
End Sub

Open in new window

Microsoft Access

Avatar of undefined
Last Comment
Murray Brown

8/22/2022 - Mon
John Tsioumpris

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

e.g.
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 : https://www.experts-exchange.com/articles/33716/Defeating-the-device-independent-bitmap-dib-format.html
ASKER CERTIFIED SOLUTION
ste5an

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Murray Brown

ASKER
Thanks for the help
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck