I am using the following code to open a linked photo with each record. It works well. The only issue is that when I get to the last record, and there is no associated photo, I get runtine error 2200: Microsoft Access can't open file 'H:\Future Store\Photos\'. Is there a way I can prevent this message from appearing.
Option Compare Database
Option Explicit
Dim filename As String, pathname As String
Private Sub Form_Activate()
'find the path of the current database
'which is where the jpegs are stored
pathname = CurrentProject.Path
End Sub
Private Sub Form_Current()
On Error GoTo Err_cmdClose_Click
'set the picture path
Me.ImgStock.Picture = pathname & "\" & Me.txtStockGraph
Exit_cmdClose_Click:
Exit Sub
Err_cmdClose_Click:
If Err.Number = 2220 Then 'can't find the file
Resume Next
Else
MsgBox Err.Description
Resume Exit_cmdClose_Click
End If
End Sub
Option Compare Database
Option Explicit
Dim filename As String, pathname As String
Private Sub Form_Activate()
'find the path of the current database
'which is where the jpegs are stored
pathname = CurrentProject.Path
End Sub
Private Sub Form_Current()
On Error GoTo Err_cmdClose_Click
'set the picture path
Me.ImgStock.Picture = pathname & "\" & Me.txtStockGraph
Exit_cmdClose_Click:
Exit Sub
Err_cmdClose_Click:
If Err.Number = 2220 Then 'can't find the file
Resume Next
Else
MsgBox Err.Description
Resume Exit_cmdClose_Click
End If
End Sub