Me.image0

  • Thread starter Thread starter Raymond Chiu
  • Start date Start date
R

Raymond Chiu

Dear all,

I have written some code on my report.Activate() event function

Dim color As Long

DoCmd.MoveSize 0, 0, 10500, 6350
Set pb = New clsPictureBox
pb.ImageControl = Me.Image0
pb.ImageForm = Me
pb.Clear
ScaleAmt = 1
color = RGB(RndInt(256), RndInt(256), RndInt(256))
pb.DrawLine 125, 125, 50, 50, color

It prompt the error in : pb.imagecontrol=me.image0
and is the statement in : pb.imageform= me, correct?
as The image0 is on the report
 
Unfortunately, Access does not seem to want to allow me to instanitate
the clsPictureBox object from within the Report at all. :-(
To get around this you can simply call a function on a Form that
contains an instance of the clsPictureBox object.

Say you have an Image control named "Image11" in the Report's PageHeader
section. Add code to the Format event of this section:

Private Sub PageHeader_Format(Cancel As Integer, FormatCount As Integer)
Me.Image11.PictureData = Forms!frmPictureBox.DrawLine(1, 1, 250, 250,
RGB(255, 0, 0))
End Sub

Now take my sample Form from the vbPictureBox MDB and add the following
function:

' Call from a report to draw on the Report's Image control

Public Function DrawLine(x As Long, y As Long, x1 As Long, y1 As Long,
color As Long) As Variant
' Call the Line Method to draw a line
pb.Clear
pb.DrawLine x, y, x1, y1, color
DoEvents
' Return the PictureBox property of this Image control
DrawLine = pb.ImageControl.PictureData

End Function


For this to work you must have the Form open when you call the DrawLine
function. Adjust the Form's name as required when you call the function
from your report.
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Dear Stephen,

How about inserting text value on the image at a certain position?
Is it possible?

Thanks for your big help

Raymond
 
Anything you can do in a Form with the vbPictureBox class you can do on
a report. Just as per the sample code I gave you simply copy and Paste
the existing Text function from the sample Form, rename it with a Public
versus Private declaration and then follow the logic of the sample code.
Give it a try and post back if you need further help. I'm leaving in a
few days for a vacation so won't be available for a week after this
Thursday.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Dear Stephen,

I am using clsPictureBox, not VbPictureBox.
Could you give me the class to import to my access and also some sample if
possible?

Thanks for your big help.

Raymond
 
Dear stephen,

I find that there is a function of outputtext which does not allow me to
print the string to a current X and Y position, not like picture Box on VB.
Please help!!

Thanks,

Raymond
 
Raymond obviously we are having some language issues here so let's start
over.

Do you simply want to:
1) Output text at a specific location on your report
2) Draw Lines/Boxes at a specific location on your report

If this is the case then you have two options.

1) Use the built in TextBox and Line controls available in Report Design
view. During the relevant report Section's Format event
move/resize/modify/whatever as required.
or
2) Use the Print or Line methods of the Report object.



--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Back
Top