[AccessD] Images (jpg files) on Access 2007 Report DetailLines(Report View)

Bob Gajewski rbgajewski at roadrunner.com
Sat Oct 8 16:36:46 CDT 2011


Hi Brad

Here is some given to me by Gustav many moons ago .. And it has worked
flawlessly ...

Regards,
Bob Gajewski

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
'******************** Code Begin ****************
'Code courtesy of Terry Kreft & Ken Getz
'(modified from Function to Subroutine)

Dim strDBName As String
Dim strDBPath As String
Dim strDBFile As String
    strDBName = CurrentDb.Name
    strDBFile = Dir(strDBName)
    strDBPath = Left(strDBName, Len(strDBName) - Len(strDBFile))
'******************** Code End ******************

'******************** Code Begin ****************
'Code courtesy of David McAfee and Gustav Brock
'(modified for database specifics)

Dim strPicture   As String
Dim strIsPicture As String
Dim strNoPicture As String

strIsPicture = strDBPath & "photos\mbr" & Format([MemberNumber], "000") &
".jpg"
strNoPicture = strDBPath & "photos\nophoto.jpg"

If Len(Dir(strIsPicture, vbNormal)) > 0 Then
    strPicture = strIsPicture
Else
    strPicture = strNoPicture
End If

Me!imgMemberPhoto.Picture = strPicture
'******************** Code End ****************** 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Brad Marks
Sent: Saturday, October 08, 2011 14:41 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Images (jpg files) on Access 2007 Report
DetailLines(Report View)

Stuart,

Thanks for the help, I appreciate it.

I put together a little test Access 2007 application and employed your ideas
on how to place images (.jpg) files on Report Detail lines.

This approach worked nicely when I opened the report with "acViewPreview".

However, when I opened the report with "acViewReport", it appears that the
Report's Detail Line "On Format" Event is not fired and therefore I am not
able to change the "Picture" property of the image to plug in the name of
the desired jpg file.

The other reports in the application that I am working on use acViewReport
so that the users can have drill-downs, dynamic sorts, and dynamic filters.
I would therefore like to stay with acViewReport if possible.  

Thanks again for the help.  I am beginning to think that I might be trying
to do something that is not easy to accomplish with acViewReport (Report
View).

Brad 



-----Original Message-----
From: accessd-bounces at databaseadvisors.com on behalf of Stuart McLachlan
Sent: Fri 10/7/2011 1:59 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Images (jpg files) on Access 2007 Report Detail
Lines(Report View)
 
I do this quite regularly with a simple text field to store the filename (
usually, I keep the images in a standard directory, just store the filename
and build the full path/filename as
required.)

Then  I just use something like this in the report:
:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) If
PhotoName > "" And Dir$(PhotoDir() & PhotoName) > "" Then
   imgPhoto.Picture = PhotosDir() & PhotoName Else
   imgPhoto.Picture = PhotosDir() & "noimage.jpg"
End If
End Sub



> 
> On Oct 7, 2011, at 12:06 PM, "Brad Marks" <BradM at blackforestltd.com>
> wrote:
> 
> > All,
> > 
> > Earlier I posted a question about Attachment fields.  I was able to 
> > find an answer to my question and I have a test application that 
> > works Okay, but it seems a bit complicated for what I am trying to 
> > do.
> > 
> > I thought that if I explained what I am trying to accomplish, maybe 
> > someone would have some insights or suggestions.
> > 
> > I am pulling "Part" information from a SQL Server database into 
> > Access 2007 via ODBC.  One of the fields in the Parts table is the 
> > location of an image of the Part.  (for example 
> > C:\Part_Images\Part001.jpg).
> > 
> > I want to be able to use an Access 2007 Report (in Report View) to 
> > display the appropriate .jpg file for each detail line on the 
> > report.
> > 
> > I am able to accomplish this via the use of a "temporary" Access 
> > table that has an Attachment field for the images.  This works, but 
> > I wonder if there is a better/simpler approach.
> > 
> > I have experimented with placing an "Image" on the Report Detail 
> > lines, with hopes of changing the Images's "Picture" property on the 
> > fly for each detail line on the report.  I cannot figure out how to 
> > do this. Perhaps Access 2007 does not allow this when using "Report 
> > View".
> > 
> > I would guess that others may have run into similar situations and 
> > may have some advice.
> > 
> > Thanks for your help,
> > 
> > Brad
> > 
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> 
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 



-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.








More information about the AccessD mailing list