Lila,
You are not testing whether any of the other 6 pictures are missing, and
setting their frame states accordingly. You need to repeat the
If Not Isnull (Me!Photo) Then
...
End If
statements for each of your additional 6 picture fields, substituting the
appropriate field names and control names in each section of code.
You'll also need to either pass the control name to the showImageFrame and
hideImageFrame subroutines, or (probably easier) simply set the visible
property of each image frame control in the code in each If statement.
Using the second option, here's a sample of what each If ... End If section
will look like, using generic field/control names:
If Not IsNull(Me!NameOfPhotoField) Then
NameOfErrormsgControl.Visible = False
res = IsRelative(Me!NameOfPhotoField)
fName = Me![NameOfImagePathField]
If (res = True) Then
fName = path & "\" & fName
End If
Me![NameOfImageFrameControl].Picture = fName
Me![NameOfImageFrameControl].Visible = True
Me.PaintPalette = Me![NameOfImageFrameControl].ObjectPalette
If (Me![NameOfImageFrameControl].Picture <> fName) Then
Me![NameOfImageFrameControl].Visible = False
NameOfErrormsgControl.Caption = "Picture not found"
NameOfErrormsgControl.Visible = True
End If
Else
Me![NameOfImageFrameControl].Visible = False
NameOfErrormsgControl.Caption = "Click Add/Change to add picture"
NameOfErrormsgControl.Visible = True
End If
Also, a single On Error Resume Next statement (at/near the top of the Sub -
the current position is fine) is all that is needed (unless you change the
error handling). The statement (which stays in effect until a different On
Error Resume statement is encountered) simply says, in effect "if there's
any error when this code runs, ignore it and continue at the next line".
You might like to comment it out while you're changing your code, since it
will hide any errors that you might produce ;-)
I notice in your reply to Arvin's answer that you ask about not using a
file. The "file" is the pathname/filename of the picture that you are
using, stored in the NameOfPhotoField in your underlying table. You do need
it, in some fashion. Whether you need the particular code that's in the
Northwind example will depend on exactly what you are storing for each
picture; the code shown (which I haven't changed) will use the picture field
entry as an absolute pathname if it finds a drive designator or UNC path
designator in the picture field, otherwise it assumes that the picture
fields are defined relative to the folder of the database itself.
HTH,
Rob
Lila said:
Actually, the picture on the first tab works just fine. It's the 6
additional
pictures on the second tab that are having the problems. For those I added
the code indicated in the following link:
http://support.microsoft.com/Default.aspx?id=148463
The code is as follows. Note that the first section is straight from
Northwind and is fine. The last 6 are as noted in above link.
Private Sub Form_Current()
' Display the picture for the current record if the image
' exists. If the file name no longer exists or the file name was blank
' for the current record, set the errormsg label caption to the
' appropriate message.
Dim res As Boolean
Dim fName As String
path = CurrentProject.path
On Error Resume Next
errormsg.Visible = False
If Not IsNull(Me!Photo) Then
res = IsRelative(Me!Photo)
fName = Me![ImagePath]
If (res = True) Then
fName = path & "\" & fName
End If
Me![ImageFrame].Picture = fName
showImageFrame
Me.PaintPalette = Me![ImageFrame].ObjectPalette
If (Me![ImageFrame].Picture <> fName) Then
hideImageFrame
errormsg.Caption = "Picture not found"
errormsg.Visible = True
End If
Else
hideImageFrame
errormsg.Caption = "Click Add/Change to add picture"
errormsg.Visible = True
End If
On Error Resume Next
Me![fabric1photoframe].Picture = Me![Fabric1Photo]
On Error Resume Next
Me![fabric2photoframe].Picture = Me![Fabric2Photo]
On Error Resume Next
Me![fabric3photoframe].Picture = Me![Fabric3Photo]
On Error Resume Next
Me![EdgeTrim Picture Frame].Picture = Me![EdgeTrim Picture Path]
On Error Resume Next
Me![FrameFinishFrame].Picture = Me![FrameFinishPicturePath]
On Error Resume Next
Me![HardSurfaceFrame].Picture = Me![HardSurfacePicturePath]
End Sub