K
Ken Cobler
I have a movie database, with the movies autonumbered (MovieID). Plus I also
load an image of each movie. My code, below, allows me not to bother with a
field for image path, since the images will all be in one spot, and all match
the MovieID number plus a ".jpg" extension.
My question: I want to create a default "No Image" picture for those
records which don't yet have pictures. Currently the form is using whatever
the last picture was, even though the picture name does not match the MovieID.
I am new to coding.
Please advise. Thank you.
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.ImageFrame.Picture = pathname & "\Images\" & Me.MovieID & ".jpg"
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
load an image of each movie. My code, below, allows me not to bother with a
field for image path, since the images will all be in one spot, and all match
the MovieID number plus a ".jpg" extension.
My question: I want to create a default "No Image" picture for those
records which don't yet have pictures. Currently the form is using whatever
the last picture was, even though the picture name does not match the MovieID.
I am new to coding.
Please advise. Thank you.
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.ImageFrame.Picture = pathname & "\Images\" & Me.MovieID & ".jpg"
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