Derek Brown
asked on
Scaling problem
When scaling a section of screen or report It draws circles as circles regardless of scaling but does scale lines and boxes. I have this very strange ratio of 140 to 42:
DrawWidth = 2
Me.ScaleLeft = -10
Me.ScaleTop = -10
Me.ScaleWidth = 140
Me.ScaleHeight = 42
With this:
DrawWidth = 2
Me.ScaleLeft = -10
Me.ScaleTop = -10
Me.ScaleWidth = 140
Me.ScaleHeight = 40
(Scale height only changed from 42 to 40) I Get
Its just a 15mm Rad circle in a 30 x 30 box
My question is what kind of ratio does 140 x 42 represent (that's the closest I can get for first drawing) and is there a way to avoid this daftness?
DrawWidth = 2
Me.ScaleLeft = -10
Me.ScaleTop = -10
Me.ScaleWidth = 140
Me.ScaleHeight = 42
With this:
DrawWidth = 2
Me.ScaleLeft = -10
Me.ScaleTop = -10
Me.ScaleWidth = 140
Me.ScaleHeight = 40
(Scale height only changed from 42 to 40) I Get
Its just a 15mm Rad circle in a 30 x 30 box
My question is what kind of ratio does 140 x 42 represent (that's the closest I can get for first drawing) and is there a way to avoid this daftness?
How about attaching a demo that illustrates your task?
ASKER
Hi Gustav
Try Report3 and in the code change A to 8 and R to 10. It all works, then change ScaleHeight to 40 and see what happens.
I must be doing something wrong?
Report3.mdb
Try Report3 and in the code change A to 8 and R to 10. It all works, then change ScaleHeight to 40 and see what happens.
I must be doing something wrong?
Report3.mdb
ASKER
It actually scales the lines or boxes which then pushes the circle out of position.
Why would a ratio of 140:42 mean anything?
Why would a ratio of 140:42 mean anything?
I don't follow. Your original circle was not pushed out of position.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Scott. It's not designed to draw a circle. I merely make the point that arcs, as a portion of circle, are not scaled whilst lines and boxes are.
Hi Gustav I should have said that it appears to send arcs off center as your comment above
This is a very small part of a huge Access DB. The program covers all a user needs. I really don't want users having to open another application just to print a report that won't be able use the already entered data.
It's just a report showing a section of a picture frame molding.
The big problem is understanding scaling. But if access can't do it?
Hi Gustav I should have said that it appears to send arcs off center as your comment above
This is a very small part of a huge Access DB. The program covers all a user needs. I really don't want users having to open another application just to print a report that won't be able use the already entered data.
It's just a report showing a section of a picture frame molding.
The big problem is understanding scaling. But if access can't do it?
Well, but we have nothing to work with.
The first drawing could be understood, the next can be anything for "non-molders", and we have very little idea of what you are trying to do neither why: What scaling, and in relation to what?
The first drawing could be understood, the next can be anything for "non-molders", and we have very little idea of what you are trying to do neither why: What scaling, and in relation to what?
It's not that Access cannot understand scaling, it's that the graphics engine in Access was designed around presenting nicely formatted data, not drawing pictures. Even with professional images on a report (which I know is different from what you're doing) they sometimes come out skewed and odd looking.
I guess what I'm saying is - don't beat a dead horse. You may find that another you'll have to work with Crystal Reports, or something of that nature, to get where you're at. I'm not trying to dissuade you from trying this, of course, only trying to let you know the limitations of VBA.
I guess what I'm saying is - don't beat a dead horse. You may find that another you'll have to work with Crystal Reports, or something of that nature, to get where you're at. I'm not trying to dissuade you from trying this, of course, only trying to let you know the limitations of VBA.
ASKER
Hi Gustav
All I am trying to do is understand the relationship between 140 scalewidth and 42 scaleheight so that when I want a line to meet a circle or arc it does exactly that. If the scale is wrong they do not intersect correctly. It unsettles me when I don't know how something works.
So it is not for a specific purpose, it's so that next time this comes up and it will I know how to handle it.
It works the same for other printers I have tested
All I am trying to do is understand the relationship between 140 scalewidth and 42 scaleheight so that when I want a line to meet a circle or arc it does exactly that. If the scale is wrong they do not intersect correctly. It unsettles me when I don't know how something works.
So it is not for a specific purpose, it's so that next time this comes up and it will I know how to handle it.
It works the same for other printers I have tested
OK.
But it might help if you posted the code.
But it might help if you posted the code.
ASKER
Well, well, well. How could I be so stupid. It's the size of the report that I created that governs the ratio. I assumed that if you were specifying the scaleleft and right and scale top and height that it would ignore the size of the underlying report scale and just put an invisible border around the drawing on the printed page. It does not. How weird is that.?
To get this to work with the specified scale ratio 140:42 you need to create a report that is 2.5cm high and 7 cm wide
The code was in the attached sample db. but here is the latest version:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim W As Variant
Dim H As Variant
Dim R As Variant
Dim A As Variant
Dim PI As Variant
Dim C As Variant
Dim Text As Variant
Dim LL As Variant
Dim RW As Variant
Dim RH As Variant
Me.FontName = Arial
Me.FontSize = 4
W = 20
H = 22
R = 4
A = 5
RW = 4
RH = 18
PI = 3.141592654
C = 2
Text = 4
LL = 3
Me.DrawWidth = 1
Me.ScaleLeft = -20
Me.ScaleTop = -20
Me.ScaleWidth = 140
Me.ScaleHeight = 42
Me.Circle (W - A - (R * H) / Sqr(A * A + H * H) + A * R / H * (1 - A / (Sqr(A * A + H * H))), R), R, 0, Atn(A / H), PI / 2
Me.Line (W, H)-(W - A + A / H * (R - (A * R) / (Sqr(A * A + H * H))), R - A * R / (Sqr(A * A + H * H))), 0
Me.Line (W, H)-(RW, H)
Me.Line (RW, H)-(RW, H - RH)
Me.Line (RW, H - RH)-(0, 4)
Me.Line (0, H - RH)-(0, 0)
Me.Line (0, 0)-(W - A - (R * H) / Sqr(A * A + H * H) + A * R / H * (1 - A / (Sqr(A * A + H * H))), 0)
Me.Line (W, H + C)-(W, H + C + LL)
Me.Line Step(0, -LL * 0.5)-Step(-0.5 * (W - Text), 0), vbRed
Me.Line Step(-Text, 0)-Step(-0.5 * (W - Text), 0)
Me.Line Step(0, LL * 0.5)-Step(0, -LL)
Me.Line (-C + -LL, H)-Step(LL, 0), 0
Me.Line Step(-0.5 * LL, 0)-Step(0, 0.5 * -(H - Text))
Me.Line Step(0, -Text)-Step(0, 0.5 * -(H - Text))
Me.Line Step(-0.5 * LL, 0)-Step(LL, 0)
If RW > 0 Then
Me.Line (C + RW, H - RH)-Step(LL, 0)
Me.Line Step(-0.5 * LL, 0)-Step(0, 0.5 * (RH - Text)), vbRed
Me.Line Step(0, Text)-Step(0, 0.5 * (RH - Text))
Me.Line (0, H - RH + (0.5 * C))-Step(0, LL)
CurrentX = -C - (0.5 * LL) - 2
CurrentY = 0.5 * (H - 0.5 * Text) - 0.5
Print H
CurrentX = (0.5 * (W - Text)) - 0.5
CurrentY = H + C + (-0.5 * LL) + 1.5
Print W
CurrentX = (0 + RW + C) - 1
CurrentY = H - RH + (0.5 * RH) - 1.5
Print RH
CurrentX = 0 + 0.2
CurrentY = H - RH + 1
Print RW
End If
End Sub
To get this to work with the specified scale ratio 140:42 you need to create a report that is 2.5cm high and 7 cm wide
The code was in the attached sample db. but here is the latest version:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim W As Variant
Dim H As Variant
Dim R As Variant
Dim A As Variant
Dim PI As Variant
Dim C As Variant
Dim Text As Variant
Dim LL As Variant
Dim RW As Variant
Dim RH As Variant
Me.FontName = Arial
Me.FontSize = 4
W = 20
H = 22
R = 4
A = 5
RW = 4
RH = 18
PI = 3.141592654
C = 2
Text = 4
LL = 3
Me.DrawWidth = 1
Me.ScaleLeft = -20
Me.ScaleTop = -20
Me.ScaleWidth = 140
Me.ScaleHeight = 42
Me.Circle (W - A - (R * H) / Sqr(A * A + H * H) + A * R / H * (1 - A / (Sqr(A * A + H * H))), R), R, 0, Atn(A / H), PI / 2
Me.Line (W, H)-(W - A + A / H * (R - (A * R) / (Sqr(A * A + H * H))), R - A * R / (Sqr(A * A + H * H))), 0
Me.Line (W, H)-(RW, H)
Me.Line (RW, H)-(RW, H - RH)
Me.Line (RW, H - RH)-(0, 4)
Me.Line (0, H - RH)-(0, 0)
Me.Line (0, 0)-(W - A - (R * H) / Sqr(A * A + H * H) + A * R / H * (1 - A / (Sqr(A * A + H * H))), 0)
Me.Line (W, H + C)-(W, H + C + LL)
Me.Line Step(0, -LL * 0.5)-Step(-0.5 * (W - Text), 0), vbRed
Me.Line Step(-Text, 0)-Step(-0.5 * (W - Text), 0)
Me.Line Step(0, LL * 0.5)-Step(0, -LL)
Me.Line (-C + -LL, H)-Step(LL, 0), 0
Me.Line Step(-0.5 * LL, 0)-Step(0, 0.5 * -(H - Text))
Me.Line Step(0, -Text)-Step(0, 0.5 * -(H - Text))
Me.Line Step(-0.5 * LL, 0)-Step(LL, 0)
If RW > 0 Then
Me.Line (C + RW, H - RH)-Step(LL, 0)
Me.Line Step(-0.5 * LL, 0)-Step(0, 0.5 * (RH - Text)), vbRed
Me.Line Step(0, Text)-Step(0, 0.5 * (RH - Text))
Me.Line (0, H - RH + (0.5 * C))-Step(0, LL)
CurrentX = -C - (0.5 * LL) - 2
CurrentY = 0.5 * (H - 0.5 * Text) - 0.5
Print H
CurrentX = (0.5 * (W - Text)) - 0.5
CurrentY = H + C + (-0.5 * LL) + 1.5
Print W
CurrentX = (0 + RW + C) - 1
CurrentY = H - RH + (0.5 * RH) - 1.5
Print RH
CurrentX = 0 + 0.2
CurrentY = H - RH + 1
Print RW
End If
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.