Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Placing a control on a report with VBA

27 views
Skip to first unread message

septimus

unread,
May 25, 2012, 6:38:24 PM5/25/12
to
I have an Access report with simple bar graphs that chart percent
values between 0 and 100. No problem there, I just use the following
line of code to size the dark rectangle (recPercentBar) on top of a
lighter colored rectangle (rec100Bar) depending on the value of a
double variable (dblValue):

Me!recPercentBar.Width = CInt(Me!rec100Bar.Width * (dblValue / 100))

Here's where the problem comes in: I now have a need for a similar bar
graph but this time the values run from -20 to 20 with 0 in the
center, like this:

----------------------------------------
-20 0 20

If I'm charting a value of -10, the rectangle on top needs to run from
-10 to 0.
If I'm charting a value of 10, the rectangle on top needs to run from
0 to 10.

So how do I control where on the report the left side of the top
rectangle falls? Just setting the width property of the rectangle no
longer suffices.

Is this something that can be done maybe with the reports CurrentX and
CurrentY properties? I haven't used them before so I'm not sure.

Thanks for your help.

Phil

unread,
May 26, 2012, 3:50:16 AM5/26/12
to
Me!recPercentBar.Left = something
Me!recPercentBar.Top = something else (though this is probably a fixed value
and need not be defined) Left is measured from the left of the report, Top is
measured from the TOP of the sextion. Measurements are in Twips. There are
1440 Trips to the inch or 567 Twips to the Cm

Phil

Evan Cater

unread,
May 26, 2012, 3:12:48 PM5/26/12
to
Yep, that's what I needed:

If dblValue > 0 Then
recPercentBar.Left = rec100Bar.Left + (rec100Bar.Width *
0.5)
recPercentBar.Width = rec100Bar.Width * (dblValue / 100)
Else
recPercentBar.Left = rec100Bar.Left + (rec100Bar.Width *
0.5) - rec100Bar.Width * (Abs(dblValue) / 100)
recPercentBar.Width = rec100Bar.Width * (Abs(dblValue) /
100)
End If

Thanks!
0 new messages