1 Attachment(s)
Print image on data report problem
I have problem here, I want to print all image on database. When I try that code and navigate the the data report during run time, only text change but the image still don't change, It should change the image according the record. Why?
Code:
' On the form
''Print all record
Unload Me
frmMenu.Picture2.Cls
frmMenu.Picture2.AutoRedraw = True
frmMenu.Picture2.ScaleMode = vbPixels
On Error GoTo error:
frmMenu.Picture2.PaintPicture LoadPicture(Pesttable.Fields("Gambar")), 0, 0, 200, 200
Set reportperosak.DataSource = Pesttable
reportperosak.Show
Code:
Private Sub DataReport_Initialize()
On Error GoTo error
'show the image from database to prit the form
'Set Me.Sections("Section1").Controls("Image1").Picture = LoadPicture(Pesttable.Fields("Gambar"))
'scale image from the image on formMenu to display on image in datareport
Dim oPic As StdPicture
Dim oImgControl As RptImage
Set oPic = LoadPicture(Pesttable.Fields("Gambar"))
Set oImgControl = reportperosak.Sections("Section1").Controls("Image1")
oImgControl.SizeMode = rptSizeStretch
oImgControl.Width = frmMenu.ScaleX(200, vbPixels, vbTwips)
oImgControl.Height = frmMenu.ScaleY(200, vbPixels, vbTwips)
Set oImgControl.Picture = oPic
error:
End Sub
Re: Print image on data report problem
Re: Print image on data report problem
Anyone know how to solve this problem? I have image file in the database. I want to print all the image from database. But the image is static ("no change") during run time. Only text change according the record. The image should change in the data report according its records while navigate the report.
Re: Print image on data report problem
You can't. The Image control on the DataReport cannot be bound to a recordset/datasource like the TextBox control. This means you can't change the image on a per record basis.
Re: Print image on data report problem
But I can view the image from the database when I do query like this.If PEST_ID is 001, I can view the image of that record. If PEST_ID = 002, I also can view the image for that records. the image change every time I do query. But why I cannot do to view all the image according the record?Do you have suggestion how I can view all the images according the records without do some query.
Quote:
Pesttable.Open "Select * from Perosak where PEST_ID ='" & Trim(frmMenu.Text20.Text) & "'", conpest, adOpenDynamic, adLockOptimistic
Set reportperosak.DataSource = Pesttable
reportperosak.Show
Re: Print image on data report problem
Quote:
Originally Posted by brucevde
You can't. The Image control on the DataReport cannot be bound to a recordset/datasource like the TextBox control. This means you can't change the image on a per record basis.
You were right, from my reading. Do you have another solution? How to bound image control to recordset like textbox?Do I have download 3 party data report?
Re: Print image on data report problem
You could create this report using the Printer object directly, just as you did with printing the ListView in your other thread.
VB comes with a report writer called Crystal Reports. It is only version 4.6 but is 1000 times better than the Data Report and is free. I think it is in the Component\Tools folder on the VB installation CD.
Other than that you would need a 3rd party report writer.