Need to default to "no Picture" in Access 2002 report

G

Guest

I am working in Access2000. I need to use a lot of pictures in my database. I
have a field named 'Picture' that is a text field and I store the path to the
image there. The following is the code I use to make Access show the correct
image on the report in an image frame.

Option Compare Databas
-----------------------------------------------------------------------------------------
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error Resume Next

Me![Image86].Picture = Me![Picture]

End Su
------------------------------------------------------------------------------------------
Private Sub Report_Activate()
On Error Resume Next
Me![Image86].Picture = Me![Picture]

End Su
-----------------------------------------------------------------------------------------
Private Sub Report_Page()
On Error Resume Next
Me![Image86].Picture = Me![Picture]

End Su
------------------------------------------------------------------------------------------
The problem is this: When Access encounters a null in the field, (there is
no picture), it defaults to the previous picture or the first picture viewed.
I want it to default to a bmp I made that says “no image available†I used
the no picture bmp to create the image control on the form in the first
place. Do I need some code that follows “On Error†to tell access to display
the no picture bmp. I am marginally proficient at code,(I know just enough to
be dangerous!)

Thanks, Pam
 
L

Larry Linson

Test for Null, and load a specific path and filename itno
Me!Image86.Picture - something like this untested, air code:

If IsNull(Me!{Picture] then
Me![Image86].Picture = strPathAndFileForNoImage
Else
Me![Image86].Picture = Me![Picture]
End If
 
G

Guest

Thanks Larry!

That code looks like it will do the job. I entered it and adjusted all of
the little syntax things Access needs to be happy, but now, it has a "type
mismatch" error with my original Me![Image86].Picture = Me![Picture]
Also, do I need to put the code into any other "on" event on the properties
of the report?
--
Pam


Larry Linson said:
Test for Null, and load a specific path and filename itno
Me!Image86.Picture - something like this untested, air code:

If IsNull(Me!{Picture] then
Me![Image86].Picture = strPathAndFileForNoImage
Else
Me![Image86].Picture = Me![Picture]
End If



Pam said:
I am working in Access2000. I need to use a lot of pictures in my database.
I
have a field named 'Picture' that is a text field and I store the path to
the
image there. The following is the code I use to make Access show the
correct
image on the report in an image frame.

Option Compare Database
-----------------------------------------------------------------------------------------
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error Resume Next

Me![Image86].Picture = Me![Picture]

End Sub
------------------------------------------------------------------------------------------
Private Sub Report_Activate()
On Error Resume Next
Me![Image86].Picture = Me![Picture]

End Sub
-----------------------------------------------------------------------------------------
Private Sub Report_Page()
On Error Resume Next
Me![Image86].Picture = Me![Picture]

End Sub
------------------------------------------------------------------------------------------
The problem is this: When Access encounters a null in the field, (there is
no picture), it defaults to the previous picture or the first picture
viewed.
I want it to default to a bmp I made that says "no image available" I used
the no picture bmp to create the image control on the form in the first
place. Do I need some code that follows "On Error" to tell access to
display
the no picture bmp. I am marginally proficient at code,(I know just enough
to
be dangerous!)

Thanks, Pam
 
G

Guest

I have discovered the answer to this perplexing problem. First, put an image
frame on the report and use the first picture in the field to make it.
Second, put a text box on the form that is controled by the field with the
path to the image, (mine is called txtImagePath). Next, view code and paste
the following code into there:
-------------------------------------------------
Option Compare Database
Function setImagePath()
Dim strImagePath As String
On Error GoTo PictureNotAvailable
strImagePath = Me.txtImageName
Me.ImageFrame.Picture = strImagePath
Exit Function

PictureNotAvailable:
strImagePath = "C:\BIA Dip Vat Database\Pictures\zNo
Picture\NoPicture.bmp"
Me.ImageFrame.Picture = strImagePath

End Function
--------------------------------------------------
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

OnFormat = setImagePath
End Sub
---------------------------------------------------

--
Pam


Pam said:
Thanks Larry!

That code looks like it will do the job. I entered it and adjusted all of
the little syntax things Access needs to be happy, but now, it has a "type
mismatch" error with my original Me![Image86].Picture = Me![Picture]
Also, do I need to put the code into any other "on" event on the properties
of the report?
--
Pam


Larry Linson said:
Test for Null, and load a specific path and filename itno
Me!Image86.Picture - something like this untested, air code:

If IsNull(Me!{Picture] then
Me![Image86].Picture = strPathAndFileForNoImage
Else
Me![Image86].Picture = Me![Picture]
End If



Pam said:
I am working in Access2000. I need to use a lot of pictures in my database.
I
have a field named 'Picture' that is a text field and I store the path to
the
image there. The following is the code I use to make Access show the
correct
image on the report in an image frame.

Option Compare Database
-----------------------------------------------------------------------------------------
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error Resume Next

Me![Image86].Picture = Me![Picture]

End Sub
------------------------------------------------------------------------------------------
Private Sub Report_Activate()
On Error Resume Next
Me![Image86].Picture = Me![Picture]

End Sub
-----------------------------------------------------------------------------------------
Private Sub Report_Page()
On Error Resume Next
Me![Image86].Picture = Me![Picture]

End Sub
------------------------------------------------------------------------------------------
The problem is this: When Access encounters a null in the field, (there is
no picture), it defaults to the previous picture or the first picture
viewed.
I want it to default to a bmp I made that says "no image available" I used
the no picture bmp to create the image control on the form in the first
place. Do I need some code that follows "On Error" to tell access to
display
the no picture bmp. I am marginally proficient at code,(I know just enough
to
be dangerous!)

Thanks, Pam
 

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