Separate Pictures In Report

K

Karl L

I am having problems inserting individual pictures into each report page. I
am doing a campus database where I need each building picture and it's
information appear as a report page. The info is a snap, just cannot get the
pictures linked. Cannot see the "Field List" for my "linked", picture
databas, only my builidng info "Field List".
 
K

Ken Sheridan

Karl:

You don't say how you are 'linking' the images, but embedding images does
cause the file size to grow alarmingly; the most efficient method is to store
the image files separately and store the path to each file in a text field,
ImagePath say, in your Buildings table. Then in the report add an unbound
lightweight Image control, Image1 say, to the detail section and in the
section's Print event procedure load the image into it with:

If Not IsNull(Me.ImagePath) Then
Me.Image1.Picture = Me.ImagePath
Me.Image1.Visible = True
Else
Me.Image1.Visible = False
End If

Note that, unlike in a form you cannot refer to a column in a report's
underlying recordset directly in code in the report's module, so you need to
include a bound ImagePath control in the detail section and set its Visible
property to False (No) to hide it.

You can do the same in a form by including the code in the form's Current
event procedure. There is one odd piece of behaviour in forms however, which
is that this moves the cursor away from its current position. To prevent
this add the following module to the database:

' module basCursor
Option Compare Database
Option Explicit

Type POINTAPI
X As Long
Y As Long
End Type

Declare Function GetCursorPos Lib "User32" (lpPoint As POINTAPI) As Long

Declare Function SetCursorPos Lib "User32" (ByVal X As Long, ByVal Y As
Long) As Long

Public lngCursorX As Long, lngCursorY As Long

Public Sub GrabCursor()

Dim dl As Long
Dim pt As POINTAPI

dl = GetCursorPos(pt)
lngCursorX = pt.X
lngCursorY = pt.Y

End Sub

Public Sub ReturnCursor()

SetCursorPos lngCursorX, lngCursorY

End Sub
' module ends

And expand the code in the form's Current event procedure slightly to:

GrabCursor

If Not IsNull(Me.ImagePath) Then
Me.Image1.Visible = True
Me.Image1.Picture = Me.ImagePath
Else
Me.Image1.Visible = False
End If

ReturnCursor

BTW when you add an Image control to a form or report you'll be prompted for
a file. Just give it any file, then in the Control sheet delete the path
from its Picture property, confirming that you do want to do this when
prompted.

Ken Sheridan
Stafford, England
 

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