Runtime error 2200 (1 Viewer)

khwaja

Registered User.
Local time
Tomorrow, 07:39
Joined
Jun 13, 2003
Messages
254
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
 

boblarson

Smeghead
Local time
Today, 14:39
Joined
Jan 12, 2001
Messages
32,059
Have a stock picture available (I use just a white background one) and set the code to this:

Code:
If Len(Me.txtStockGraph & vbNullString) > 0 Then
   Me.ImgStock.Picture = pathname & "\" & Me.txtStockGraph
Else
   Me.ImgStock.Picture = pathname & "\blank.jpg"
End If
 

khwaja

Registered User.
Local time
Tomorrow, 07:39
Joined
Jun 13, 2003
Messages
254
Fantastic work around. Really appreciate your help. Regards
 

Users who are viewing this thread

Top Bottom