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
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