How do I automatically refresh an image on a form after changing it?

Pooks_35

Registered User.
Local time
Yesterday, 16:30
Joined
Mar 14, 2013
Messages
54
I have a unbound object in a subform call imgPicture. I want the user to be able to click a command button to choose a picture to change the picture in imgPicture. In the code below everything is working except the immediate change to the picture. For the picture to update I either need to move to a new record or click on the current photo. How do I get the photo to automatically change so the user doesn't have to move to a new record or click on the photo?
Thanks for any help you can provide!

Private Sub cmdInsertPic_Click()
Dim OFN As OPENFILENAME
On Error GoTo Err_cmdInsertPic_Click

' Set options for dialog box.
With OFN
.lpstrTitle = "Images"
If Not IsNull([PicFile]) Then .lpstrFile = [PicFile]
.flags = &H1804 ' OFN_FileMustExist + OFN_PathMustExist + OFN_HideReadOnly
.lpstrFilter = MakeFilterString("Image files (*.bmp;*.gif;*.jpg;*.wmf)", "*.bmp;*.gif;*.jpg;*.wmf", _
"All files (*.*)", "*.*")
End With

If OpenDialog(OFN) Then
[PicFile] = OFN.lpstrFile
Forms!frmPicExample!picsubform![imgPicture].Picture = [PicFile]
SysCmd acSysCmdSetStatus, "Afbeelding: '" & [PicFile] & "'."
End If
Exit Sub

Me!picsubform.PicFile = "Path to new file"
Err_cmdInsertPic_Click:
MsgBox Err.Description, vbExclamation
End Sub
 
You could try Me.Requery (my guess) but maybe you can requery the control.

More info here

I don't think your logic lets you get to this line of code
Code:
Me!picsubform.PicFile = "Path to new file"
seems the exit Sub immediately above gets executed regardless of the IF condition.
 
I tried the requery and that didn't work.
The code below was an attempt from all the searching I did to try and find an answer. It wouldn't be an issue for me to leave it as it is, however the end users of this database need it as user friendly as possible because they are NOT tech savy.
Me!picsubform.PicFile = "Path to new file"
 

Users who are viewing this thread

Back
Top Bottom