Image display problem

S

Skip

I have an Access 02 report with an image box called ImageFrame that is linked
to the following code:

Dim picpath As String
Dim sFile As String
[imageframe].Picture = ""
sFile = "s:\photos\R" & "" & PROPERTY_ID & "" & "*.jpg"
picpath = Dir(sFile)
If picpath <> "" Then
sFile = "S:\Photos\" & picpath
[imageframe].Picture = sFile
[imageframe].Picture = ""
End If
End Sub

The report works great when a file exists but if there is no photo, the last
photo will display in the imageframe. It looks like the code is working right
but the imageframe is messed up? I have the properties on the image box:

Name:ImageFrame
Picture Frame: Embedded
Size Mode: Zoom
Visible: No

Any ideas why I can't get the image box on the report to be empty is a photo
is not available? Maybe it is the code, I'm not a great code writer. Any
ideas would be great.
 
T

Terry

Skip,

Set the visible property to false. I don't think the image
control likes to exist without athe picture property set.

[imageframe].visible = false

Should do the trick.

HTH

Terry
-----Original Message-----
I have an Access 02 report with an image box called ImageFrame that is linked
to the following code:

Dim picpath As String
Dim sFile As String
[imageframe].Picture = ""
sFile = "s:\photos\R" & "" & PROPERTY_ID & "" & "*.jpg"
picpath = Dir(sFile)
If picpath <> "" Then
sFile = "S:\Photos\" & picpath
[imageframe].Picture = sFile
[imageframe].Picture = ""
End If
End Sub

The report works great when a file exists but if there is no photo, the last
photo will display in the imageframe. It looks like the code is working right
but the imageframe is messed up? I have the properties
 
S

Skip

It worked but I had to through in another If statement. Maybe it could have
been done better but this is how I got it to work:

Dim picpath As String
Dim sFile As String
[ImageFrame].Picture = ""
sFile = "s:\photos\R" & "" & PROPERTY_ID & "" & "*.jpg"
picpath = Dir(sFile)
If picpath <> "" Then
[ImageFrame].Visible = True
If picpath <> "" Then
sFile = "S:\Photos\" & picpath
[ImageFrame].Picture = sFile
End If
End If
If picpath = "" Then
[ImageFrame].Visible = False
[ImageFrame].Picture = ""
End If
End Sub

Terry said:
Skip,

Set the visible property to false. I don't think the image
control likes to exist without athe picture property set.

[imageframe].visible = false

Should do the trick.

HTH

Terry
-----Original Message-----
I have an Access 02 report with an image box called ImageFrame that is linked
to the following code:

Dim picpath As String
Dim sFile As String
[imageframe].Picture = ""
sFile = "s:\photos\R" & "" & PROPERTY_ID & "" & "*.jpg"
picpath = Dir(sFile)
If picpath <> "" Then
sFile = "S:\Photos\" & picpath
[imageframe].Picture = sFile
[imageframe].Picture = ""
End If
End Sub

The report works great when a file exists but if there is no photo, the last
photo will display in the imageframe. It looks like the code is working right
but the imageframe is messed up? I have the properties
Name:ImageFrame
Picture Frame: Embedded
Size Mode: Zoom
Visible: No

Any ideas why I can't get the image box on the report to be empty is a photo
is not available? Maybe it is the code, I'm not a great code writer. Any
ideas would be great.

.
 
T

Terry

Skip,

It probably could have been done 50 different ways - as to
what is the best way .... ? The main thing is you are
working. Glad to have helped.

Terry
-----Original Message-----
It worked but I had to through in another If statement. Maybe it could have
been done better but this is how I got it to work:

Dim picpath As String
Dim sFile As String
[ImageFrame].Picture = ""
sFile = "s:\photos\R" & "" & PROPERTY_ID & "" & "*.jpg"
picpath = Dir(sFile)
If picpath <> "" Then
[ImageFrame].Visible = True
If picpath <> "" Then
sFile = "S:\Photos\" & picpath
[ImageFrame].Picture = sFile
End If
End If
If picpath = "" Then
[ImageFrame].Visible = False
[ImageFrame].Picture = ""
End If
End Sub

Terry said:
Skip,

Set the visible property to false. I don't think the image
control likes to exist without athe picture property set.

[imageframe].visible = false

Should do the trick.

HTH

Terry
-----Original Message-----
I have an Access 02 report with an image box called ImageFrame that is linked
to the following code:

Dim picpath As String
Dim sFile As String
[imageframe].Picture = ""
sFile = "s:\photos\R" & "" & PROPERTY_ID & "" & "*.jpg"
picpath = Dir(sFile)
If picpath <> "" Then
sFile = "S:\Photos\" & picpath
[imageframe].Picture = sFile
[imageframe].Picture = ""
End If
End Sub

The report works great when a file exists but if there
is
no photo, the last
photo will display in the imageframe. It looks like
the
code is working right
but the imageframe is messed up? I have the
properties
Name:ImageFrame
Picture Frame: Embedded
Size Mode: Zoom
Visible: No

Any ideas why I can't get the image box on the report
to
be empty is a photo
is not available? Maybe it is the code, I'm not a
great
code writer. Any
ideas would be great.

.
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top