We help IT Professionals succeed at work.
Get Started

Access VBA change an image on a different form

Murray Brown
Murray Brown asked
Last Modified: 2020-02-03
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

Watch Question
Senior Developer
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE