Invalid use of Me keyword

J

JOM

With the help of Ken Sheridian, here is a code to draw a line in my report
but I am having an error, Invalid use of Me keyword... Anyone out there to me
help...

Sub DrawLine()

Dim lngColor As Long
Dim sngHeight As Single

' Set scale to twips
Me.ScaleMode = 1
' Set line width in pixels
Me.DrawWidth = 5
' Set height to artificially high value
sngHeight = 14400
' Make colour black
lngColor = RGB(0, 0, 0)
' Draw line 2 inches in from left margin
Me.Line (2880, 0)-(2880, sngHeight), lngColor

End Sub

Then you call it in the detail section's Print event procedure with:

' Call the Drawline procedure
DrawLine
 
G

Graham Mandeno

"Me" is a reference to the current instance of a class that is executing and
is therefore available only in a class module.

My guess is that you have put Sub DrawLine() in a standard module. Move it
to the report's class module (the same module that contains the Detail_Print
procedure) and you should be fine. In fact, unless you call DrawLine from
other places in your code, you can dispense with the separate Sub altogether
and just move the code to the Detail_Print procedure.
 
O

Ofer

I tried the code, and it works
Where did you put the DrawLine() Sub?

It should be located under the report, incase you created it in a module
 
J

JOM

U are right, I put the code in the wrong place!


Ofer said:
I tried the code, and it works
Where did you put the DrawLine() Sub?

It should be located under the report, incase you created it in a module
 

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