Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Draw a Horizontal Line 1

Status
Not open for further replies.

pbrown2

Technical User
Jun 23, 2003
322
US
There is a horizontal line that I need to place in a specific place on the report. However, when I try to move its position via its properties, Access rounds the position which causes it to be too far left/right of the needed position.
I know the below will draw a vertical line via code in the On Format or On Print within the report. However, I have been unable to find how to change it to draw a horizontal line.

Dim x1 As Single, Y1 As Single
Dim x2 As Single, Y2 As Single

Dim Color As Long

' Specify unit of measurement for coordinates on a page...
Me.ScaleMode = 5 ' Specify that measurement occur in inches.

' Set line to print 5 inches from the left margin.
x1 = 3.48
x2 = 3.48
' Set line to print from the top of the detail section
' to a maximum height of 22 inches.
Y1 = 0
Y2 = 22
Me.DrawWidth = 10 ' Width of the line (in pixels).

Color = RGB(0, 0, 0) ' Use black line color.
'Color1 = RGB(2050, 300, 0)

' Draw the line with the Line method.
Me.Line (x1, Y1)-(x2, Y2), Color


Any suggestions?

Thank you for any and all help,

PBrown
 
In code, you must use twips to reference locations....

1 inch = 1440 twips

****************************
Computers are possibly the most un-intelligent things ever invented, yet we let them control the world. Possibly a reflection of our own stupidity.

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
Could you please provide an example? Where would this go?

Thank you for any and all help,

PBrown
 
In your code lines:

' Specify unit of measurement for coordinates on a page...
Me.ScaleMode = 5 ' Specify that measurement occur in inches.

' Set line to print 5 inches from the left margin.
x1 = 3.48
x2 = 3.48
' Set line to print from the top of the detail section
' to a maximum height of 22 inches.
Y1 = 0
Y2 = 22
Me.DrawWidth = 10 ' Width of the line (in pixels).

Color = RGB(0, 0, 0) ' Use black line color.
'Color1 = RGB(2050, 300, 0)

' Draw the line with the Line method.
Me.Line (x1, Y1)-(x2, Y2), Color

you need to change any reference to inches to twips....so for example, your Y2 is currently 22 (inches) and you need to change it to 31680 (22 inches * 1440 twips per inch). You need to make these changes throughout all you code as you must use twips in vba code.

****************************
Computers are possibly the most un-intelligent things ever invented, yet we let them control the world. Possibly a reflection of our own stupidity.

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
Or, to keep it somewhat readable:

Const TwipsPerInch = 1440

x1 = 3.48 * TwipsPerInch
x2 = 3.48 * TwipsPerInch

etc.


 
sfm6s524,

agree on the const...if you are new to the programming area it can make thing much more readable....I just am so used to doing the 1 inch = 1440 twips in my code directly I forgot about that....thanks for the assist. have a star.

****************************
Computers are possibly the most un-intelligent things ever invented, yet we let them control the world. Possibly a reflection of our own stupidity.

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top