Link to home
Start Free TrialLog in
Avatar of JonasBand
JonasBand

asked on

URGENT PLEASE : inserting pictures from a DataBase into a data report

I have a VISUAL BASIC application where, in an ACCESS database file I have pointers to pictures (either bmp or jpg files). I need to write a report where, beside other data presented in each record, I have also to print the picture. Can somebody help me on how to do that? Is there any way that i can access a data report image control at run time, and set its PICTURE property ? That would solve the problem (I think). Thank you for your enormous help !
Avatar of inthedark
inthedark
Flag of United Kingdom of Great Britain and Northern Ireland image

Step 1 load the pciture into a pictrue box, I assume you can do this.

Step 2 print the picture:

Printer.PaintPictrue picExample DX,DY[,DW.DH,SX,SY,SW,SH,rop]

Where D,S = destination/source coordinates.

And rop is a raster operation:

ROP = RasterOpConstants.xxxx ' choose one

You can use the raster op. so overlay images.

In you case you just need to specify the destination

DX = 1440 * 1 ' 1 inch from left
DY = 1440 * 2 ' 2 inches from top

Printer.PaintPictrue picExample DX,DY


Furthermore, when you load your picture you need to set picExample.AutoSize = True

When you print you may wish to reduce/enlarge the size.  You can do this but it is a good idea to maintain aspect ratio. To maintain aspect ratio after you load your pic. stove the orriginal width an height:

sh = picExample.Height
sw = picExample.Width

So on your page you may wish to allocate 2 inches square to accomodate the picture.

So we need to find which measurement is largest, width or height.

If SW>SH then
   NewWidth = 1440 * 2 ' 2 inches wide
   NewHeight = NewWidth * SH/SW ' maintain aspect relativ to width
Else
   NewHeight = 1440 * 2 ' 2 inches high
   NewWidtht = NewHeight * SW/SH ' maintain aspect relative to height
End If

' Now expand/reduce picture to fit into required size

Printer.PaintPictrue picExample DX, DY, NewWidth, NewHeight


You can also use the PaintPicture method on a form or picture box.
Avatar of JonasBand
JonasBand

ASKER

Hi Inthedark !
 Thank you for your prompt response, but I think I did not explain correctly what I need. I actually have a report formatted (I used a Data Report) with the data I get from each record in the Database (for instance these are Workers data), and i have to include the person´s picture in the report also. The report will look something like :

   _________________________________________________
  x                                                  x
  x  Worker data zzzzzzzzzzzzzzz                     x
  x  More data zzzzzzzzz zzzzzzzzzz zz               x
  x                                                  x
  x                                __________        x
  x  data zzzzz zzzzzz zzzz       x          x       x
  x                               x          x       x
  x                               x  Photo   x       x
  x                               x          x       x
  x data zzzzzzzzzz zzzzzzzzzz    x          x       x
  x                                __________        x
  x _________________________________________________x
 
 This format will be repeated for each worker. I could probably print 3 or 4 per page. The area above marked as Photo is where i need to insert the picture. Can you still help me with that ?
Sorry I don't use DataReport.
Hi JonasBand,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.

JonasBand, Please DO NOT accept THIS comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
ASKER CERTIFIED SOLUTION
Avatar of SpideyMod
SpideyMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial