I have an access database that someone else set up for me many years ago. Its shows images of my cards in a form for each record. When I add a new card I could click on the image in the continuous form and it would open up a dialouge box for me to select the image. When I selected the image it would save the path of that image to the data table so that every time I viewed the form for that record it then showed that image. Below is the code I have for this. But it suddenly stopped working and always gives me the cancelled operation error. The file path is correct. Can anyone help with this.
Private Sub photoideaframe_DblClick(Cancel As Integer)
‘ Purpose : Use the API to open the Windows Common Dialog for the user to select a file
‘ Parameters : Cancel — if set to true on Exit, cancels opening the form
‘ Created/Modified : 6/24/99,
‘On Error GoTo ErrHandler
Dim lngFlags As Long
Dim strPathAndFile As String
Me.AllowDeletions = False
strPathAndFile = ahtCommonFileOpenSave(InitialDir:=”C:UsersselinOneDrivecardsIdeas”, _
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:=”Choose an Image File”)
If Len(strPathAndFile) = 0 Then
If (Eval("MsgBox (' You Cancelled the Operation!@The previous picture will be kept RS.@@',10,' Add Image')")) = vbYes Then
MsgBox "user clicked YES"
Else
End If
Else
Me![photoideaframe].Picture = strPathAndFile
Me![photoidea] = strPathAndFile
End If
' Since you passed in a variable for lngFlags,
' the function places the output flags value in the variable.
Exit_Sub:
Exit Sub
ErrHandler:
MsgBox “Error ” & Err.number & ” : ” & Err.Description & ” in Form_Open”, vbExclamation, “Images in Access Example”
Resume Exit_Sub
End Sub
Selina Schafer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.