Access: rectangle object - programmatically resizing rectangle

mytfein
mytfein used Ask the Experts™
on
Hi EE,
I learned from this site how to resize a rectangle using the WIDTH property

http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_20643295.html?sfQueryTermInfo=1+graph+report+sub

for ex:
   rctHPbar.Width = (Me.txtHPcount / 100) * (1440 * lngBarMaxInches)

I am having trouble modifying the HEIGHT property of rectangel.
It is growing SOUTHWARD, and would like it to grow NORTHWARD.

Any ideas? (I tried multiplying the above by -1, but got an error msg)

tx, sandra
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
you say you have a problem with the height formula, but you provided only the width formula.
can you post your problematic height formula, so i can suggest a solution?
Database Architect / Application Developer
Top Expert 2007
Commented:
Hey S ...

In case no one knows ... there is a LOT of sizing code in various places on this site:

http://www.lebans.com/

mx
Scott McDaniel (EE MVE )Infotrakker Software
Most Valuable Expert 2012
Top Expert 2014
Commented:
Controls in Access (and every other programming language I've dealt with) are positioned based on Top and Left properties ... if you want something to "grow northward", you basically want to reposition it (i.e. move the Top value) ... then change the height.
How to Generate Services Revenue the Easiest Way

This Tuesday! Learn key insights about modern cyber protection services & gain practical strategies to skyrocket business:

- What it takes to build a cloud service portfolio
- How to determine which services will help your unique business grow
- Various use-cases and examples

Author

Commented:
Thx guys for replying:

Erez:
     it's the same formula, just used   "dot" Height  as in:  .Height =

Mx:
     Thx, amazing! I could spend days here.....

LSM:
a)      I see a Top property,
b)      so if the rect is set at 3 ", and I should set top property to 1"  to "mimic" that
      column is growing northward
               - but -
      really growing southward from a higher top value point
                      to give an illusion of going northward
c) if (b) is true, the challenge is in correctly calculating the top value from which to start the
    movement south?

    There is no bottom property. If there was,  perhaps a formula could be created to calculate
    top value and length of bar.

Guys, I'm going out for a walk to rest my brain, will be in touch.... tx, s

    please reply....tx, sandra          
Commented:
you can try this for each iteration (you'll need 2 commands)
rctHPbar.Top = rctHPbar.Top - ((Me.txtHPcount / 100) * (1440 * lngBarMaxInches)-rctHPbar.Height )
rctHPbar.Height = (Me.txtHPcount / 100) * (1440 * lngBarMaxInches)
and in english it's something like
the top is decreased by the amount of changed height, then the height is actually changed

 
Scott McDaniel (EE MVE )Infotrakker Software
Most Valuable Expert 2012
Top Expert 2014

Commented:
The other issue I see is interaction with other controls. I'm not sure how well the controls above this one will resize if you do this.

Why does the control need to grow upwards?

< There is no bottom property>

No, but there is Top + Height, which is, in effect, the "bottom".

Author

Commented:
Hi Erez,

Thx for the code.
I'm getting an error: 2100 the control or subform control is too large for this location...
let me see if I can post a test mdb, in case you want see the error...

tx, s

Author

Commented:
Hi LSM,
Progression of events:
a) First created Access/MS graph for all courses for 1st year students
    screen shot 1
b) User really wants an arrow pointing to the bar that the student falls under.
     This graph is from a pdf from a website. I was told that this sample was created 10 years ago
     so no on technical at this website for me to talk to.
    screen shot 2
c) so I posted asking if possible to add "moving" arrow to graph
     http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_24583997.html

     PuppyDogBuddy gave me code for arrows, have not explored it yet as his sample says
     ActiveSheet, and I'm working out of Access

d)   Also while waiting for an EE answer of (c) figured I would try another approach to have
     another option to show my user

     using an old EE post: listed in this post in my initial quest., I learned about resizing rectangles,
     so i created a 2 column self-graph report
     3rd screen shot

e) I was thinking, in case user wants the bars vertical instead of horizontal,
     so I posted this quest.
     4th screen shot (in design view - bec. not working)

f) Also, I posted at EE inquirying about Harvard Graphics and other possible chart software that
    could give me the control of drawing an arrow programmatically.

g) attached test mdb

h) btw, pls visit (c) if you have any thoughts....
tx for your time, s
     
FridayGraph.GIF
GraphWithArrows.GIF
HorizSelfGraph.GIF
VertSelfGraph.GIF
090720-graph.mdb
Scott McDaniel (EE MVE )Infotrakker Software
Most Valuable Expert 2012
Top Expert 2014

Commented:
I believe you'd need two separate images for each one (or two different reports, one with horizontal grapsh and one with vertical graphs. Moving controls during runtime is doable, but often doesn't product positive results (since when/where they're moved can have an impact on the final rendering).

Author

Commented:
Hi LSM,

oh i will not be mixing controls...

first experimented with sefl-graph: horizontal direction
I'm actually proud of it....

In case, user wants vertical to look like the pdf sample above, i began experimenting with
self-vertical

if i could get arrows to work on MS graph as per (c), then that would make me happy, too.
Just wanted to try all kinds of graphs for user to pick from....

tx, s
Scott McDaniel (EE MVE )Infotrakker Software
Most Valuable Expert 2012
Top Expert 2014

Commented:
Still, you'll be better off with two different reports, although I'd do some "user studies" to see if something like this is a desirable feature, or if you're wasting time (can't tell you how many times that has happened <g>).

Author

Commented:
Hi everyone,

this is the test mdb, tx, s
090720-graph.mdb

Author

Commented:
Hi LSM,

2 diff reports, do you mean:
a) horizontal bar direction
b) vertical bar direction

if so, that's what I am doing. If i get vertical to run easily, will go with vertical.
if it's not easy, will tell that to user .....

tx for your help guys, will be in touch tomm., tx, s
Commented:
referring to the error message about the control being too big...
just to see if the method is right, and only the values go beyond, you can try the following
your rectangle, in design view is quite "tall", which means that if you set it's top value first somewhere down the report, it's too tall to fit in
set it's height to 0 every time at the beginning of the event, and then reset it to whatever after it's positioned in the right place
and for starters, enlarge your report to fit just about anything, and see if that prevents the error, then procede from there...

Author

Commented:
Hi Erez,
I understand you... I am having trouble... maybe this is not possible...sigh....
a) If I just run to graph one row, by putting a filter on my query for:  "MEDI 1100" course
    I do not get an error about control size.
b) While I expanded report to portrait: 8 by 11
    when I run with many records, the error msgs occurs
c) I just realized this morning:
    I do not understand the  2nd subtraction of height here:
    rctHPbar.Top = rctHPbar.Top - ((Me.txtHPcount / 100) * (1440 * lngBarMaxInches)-rctHPbar.Height
d) If i wanted to dissect the code by creating variables such as:
          BarLength = Me.txtHPcount / 100
          RevisedTop =   math formula
     Would I make these fields: a Double data type to capture decimal numbers?
   
Pls advise, i think it's time to close this post as resolved, as i did get info... and perhaps open new related posts...
tx, s
Commented:
a+b) best way to find out is enter debug when the error occurs, then check for the values to find which one is faulting
c+d) i think that's a great idea to use variables that reach the value first, and only then apply them to the rectangle, for the data type Long will always cover every size you need (and it's 32bit windows native size), but then you'll need to use myLongVar=cLng(x/y)
now for the formula:
check for the maximum size you want for the bar, and create
const MaxHeight As Long=(the maximum value from above comes here)
and the lowest point your bar reaches (the base of the bar), and create
const StartTop As Long=(the value from above comes here)
now comes
BarLength=MaxLength/100*Me.txtHPcount
BarTop=startTop-BarLength
and now it's time for
rctHPbar.Top = BarTop
rctHPbar.Height = BarLength  

Author

Commented:
Hi Erez,
Thx for writing....

Pls i need this post as resolved,  and split the points bec. everyone offered ....
(another EE   recently explained to me, that too many quests. in one post are not allowed... so want
to abide by rules)

then I will post a related post, where you can answer...... if you like....

I will send you the link of new post so that you can jump in.... tx, sandra

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial