dbTalk Databases Forums  

Placing a control on a report with VBA

comp.databases.ms-access comp.databases.ms-access


Discuss Placing a control on a report with VBA in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
septimus
 
Posts: n/a

Default Placing a control on a report with VBA - 05-25-2012 , 05:38 PM






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.

Reply With Quote
  #2  
Old   
Phil
 
Posts: n/a

Default Re: Placing a control on a report with VBA - 05-26-2012 , 02:50 AM






On 25/05/2012 23:38:24, septimus wrote:
Quote:
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.

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

Reply With Quote
  #3  
Old   
Evan Cater
 
Posts: n/a

Default Re: Placing a control on a report with VBA - 05-26-2012 , 02:12 PM



On May 26, 2:50*am, "Phil" <p... (AT) stantonfamily (DOT) co.uk> wrote:
Quote:
On 25/05/2012 23:38:24, septimus wrote:









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.

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
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!

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.