Avatar of Liberty4all
Liberty4all
Flag for United States of America asked on

Moving a control to front or back in an Access 2003 report using VBA

I have some rectangles in an Access 2003 report that expand or contract based upon values in certain fields.  The rectangles are essentially "stacked" upon one another so the shorter ones are not covered up by those which are longer.  This process works well but occassionally the smaller ones have values that exceed the next size and thus cover up those that are usually longer.  The rectangles display in color which requires the back style property to be normal.  Thus, setting the back style property to transparent is not an option.

I think the solution is to add code to send the short rectangle control to the front or back depending on its length relative to other fields.  What I don't know is the syntax needed to accomplish this.  I'm guessing it would be similar to the following.

If Me. Box1.value > Me.Box2.value then
Me. Box1.SEND TO BACK
Else
Me.Box1.SEND TO FRONT
End if

I would appreciate any suggestions on how to do this, or if another approach would be better.
Microsoft Access

Avatar of undefined
Last Comment
Liberty4all

8/22/2022 - Mon
SOLUTION
Rey Obrero (Capricorn1)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Jim Dettman (EE MVE)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP 2010-2015

I uses the following code to dynamically resize "Boxes" to fit t

see: http://lebans.com/PrintLines.htm

PrintLinesClass - Create Vertical lines, Borders and boxes with the addition of a simple to use Class to your project.


    How to create a margin for your TextBox.
    How to Draw Vertical lines the entire vertical length of your Report.
    How to Draw a Grid.
    How to force the contents of a Memo field to fit within a fixed sized control.
    Lots of other stuff!


Jim Dettman (EE MVE)

Yes, but the problem is not changing the size, but the fact that changing the size ruines the layout they've setup, which is a "stacked" series of rectangles.

They need to change the z layout order.

I wonder though if all the rectangles could be drawn in order in the OnPage event?

A thought...

Jim.
Liberty4all

ASKER
For now I will accept the response of capricorn1 and Jim Dettman.  I can live with what I have and recognize the issue is essentially a limitation within Access.  Jim's second comment suggests a possible alternative to consider but time constraints prevent me from exploring it.  I appreciate everyone's quick response.  I will keep the comments from the HiTechCoach for future reference.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck