That sounds like you don't understand the information in the link I posted,
and you've simply put the published code into the double-click event of your
image control. Doing that will flag these lines as errors, since they are
public declarations which must appear before any functions/subroutines (ie.
at the top of the module). The code at
http://www.mvps.org/access/api/api0018.htm must be pasted into a standard
module (which cannot have the same name as any of the routines in it - in my
applications I generally put such routines into a module named
APIFunctions). The double-click event of the image control simply calls
this code; all it really needs is a declaration and a single line of code:
Dim strReturn as String
strReturn = fHandleFile(txtImageFile, WIN_NORMAL)
I add some additional code to deal with the possible error conditions
returned (in strReturn) by the fHandleFile function. This is the actual
code from one of my applications (it's actually from a textbox control
containing the image path/filename, and this routine is called from the
double-click event of the image control - there are two controls in my form
which a user can double-click to open the image file for editing) :
Private Sub txtImageFile_DblClick(Cancel As Integer)
On Error GoTo txtImageFile_DblClick_Error
Dim strReturn As String
If Not IsNull(txtImageFile) Then
strReturn = fHandleFile(txtImageFile, WIN_NORMAL)
Select Case Val(strReturn)
Case 0, 11, 31
MsgBox strReturn
Case 2
MsgBox "The file was not found." & vbNewLine & _
"It may have been moved or deleted." & vbNewLine & vbNewLine & _
"Use the 'Insert Image' button to re-link to the file if desired.",
vbInformation, "File not found"
Case 3
MsgBox "The path to this file was not found." & vbNewLine & _
"A network resource may be unavailable (perhaps temporarily)." &
vbNewLine & vbNewLine & _
"You may use the 'Insert Image' button to attempt to re-link to the
file.", vbInformation, "Path not found"
Case Else
End Select
End If
On Error GoTo 0
Exit Sub
txtImageFile_DblClick_Error:
If Err.Number = 490 Then MsgBox "The file was not found." & vbNewLine
& _
"It may have been moved or deleted." & vbNewLine & vbNewLine & _
"Use the Insert Image button to re-link to the file if desired.",
vbInformation, "File not found"
Resume Next
Else
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
txtImageFile_DblClick of VBA Document Form_sbfrmArising_Remarks"
End If
End Sub
Again, HTH,
Rob