A little perplexed here

B

Bill

A2K-SP3

I use an image control that is superimposed upon
an unbound OLE object control to insert pictures
into a report during formatting. The purpose of the
unbound OLE object is to provide event opportunity,
which is un-available in an image control, to change
the picture path as each record in the RecordSource
is processed. As such, I have a function invocation
in the Control Source for the OLE object:
=ImagePath([Photo])

The function code:
Public Function ImagePath(PictureName As Variant) As Variant
'================================================================================
' This function sets the fully qualified path to a jpg image, as specified
by
' the name stored in a field of the current RecordSource, as represented
here by
' the parameter "PictureName". If there is no name specified, set the
picture
' property to Null to effect a blank image.
'================================================================================
Dim Folder As String
Debug.Print "IN: [" & Me.ImageBox.Picture & "] [" & PictureName & "]"

Folder = "c:\KImages\"

If IsNull(PictureName) Or Len(Trim(PictureName)) = 0 Then 'Name in
"Photo" field of RecordSource
Me.ImageBox.Picture = "" 'No name,
leave picture area blank.
Else
Me.ImageBox.Picture = Folder & PictureName & ".jpg" 'Put path in
the image control
End If

As a test case, I have 4 records in the RecordSource for the
report in which the 1st and 3rd records have a "Photo"
field of Null, while the 2nd and 4th have the strings "Jsmith"
and "Cjones" respectively.

Notice in the Debug.Print output below that the assignment
statement Me.ImageBox.Picture = "" does not appear to have
any effect on the picture property when the PictureName is null.
I can't figure out how to essentially force that property to revert
back to its initial state, namely "(none)".

IN: [(none)] []
OUT: [(none)] []
IN: [(none)] [Jsmith]
OUT: [c:\KImages\Jsmith.jpg] [Jsmith]
IN: [c:\KImages\Jsmith.jpg] []
OUT: [c:\KImages\Jsmith.jpg] [] <<<<<<<<<<<<
IN: [c:\KImages\Jsmith.jpg] [Cjones] <<<<<<<<<<<<
OUT: [c:\KImages\Cjones.jpg] [Cjones]

I've tried setting the picture property to "(none)", Null,
"none" and "" as I "shot-gunned" for an answer. Anyone
have an idea?

Thanks,
Bill
 
D

Duane Hookom

I would set the image control visible property to No where there is no
picture. Make sure you set the image to visible when there is a picture.
 
B

Bill

Boy, do I feel dumb. Why I didn't think of that is
anyone's guess. Perhaps because I didn't have on
my "forms cap".... or probably another brain-dead
experience is more like it.
Thanks Duane,
Bill


Duane Hookom said:
I would set the image control visible property to No where there is no
picture. Make sure you set the image to visible when there is a picture.

--
Duane Hookom
MS Access MVP
--

Bill said:
A2K-SP3

I use an image control that is superimposed upon
an unbound OLE object control to insert pictures
into a report during formatting. The purpose of the
unbound OLE object is to provide event opportunity,
which is un-available in an image control, to change
the picture path as each record in the RecordSource
is processed. As such, I have a function invocation
in the Control Source for the OLE object:
=ImagePath([Photo])

The function code:
Public Function ImagePath(PictureName As Variant) As Variant
'================================================================================
' This function sets the fully qualified path to a jpg image, as
specified by
' the name stored in a field of the current RecordSource, as represented
here by
' the parameter "PictureName". If there is no name specified, set the
picture
' property to Null to effect a blank image.
'================================================================================
Dim Folder As String
Debug.Print "IN: [" & Me.ImageBox.Picture & "] [" & PictureName & "]"

Folder = "c:\KImages\"

If IsNull(PictureName) Or Len(Trim(PictureName)) = 0 Then 'Name in
"Photo" field of RecordSource
Me.ImageBox.Picture = "" 'No name,
leave picture area blank.
Else
Me.ImageBox.Picture = Folder & PictureName & ".jpg" 'Put path
in the image control
End If

As a test case, I have 4 records in the RecordSource for the
report in which the 1st and 3rd records have a "Photo"
field of Null, while the 2nd and 4th have the strings "Jsmith"
and "Cjones" respectively.

Notice in the Debug.Print output below that the assignment
statement Me.ImageBox.Picture = "" does not appear to have
any effect on the picture property when the PictureName is null.
I can't figure out how to essentially force that property to revert
back to its initial state, namely "(none)".

IN: [(none)] []
OUT: [(none)] []
IN: [(none)] [Jsmith]
OUT: [c:\KImages\Jsmith.jpg] [Jsmith]
IN: [c:\KImages\Jsmith.jpg] []
OUT: [c:\KImages\Jsmith.jpg] [] <<<<<<<<<<<<
IN: [c:\KImages\Jsmith.jpg] [Cjones] <<<<<<<<<<<<
OUT: [c:\KImages\Cjones.jpg] [Cjones]

I've tried setting the picture property to "(none)", Null,
"none" and "" as I "shot-gunned" for an answer. Anyone
have an idea?

Thanks,
Bill
 

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