MS Access 2010 - How to place a border around a associate label with control

Hi Experts,

I have a report that I would like to put a border around an associated label on the report.

I have tried to do this but it puts a border around each field.

so I have one label and one textbox that I associated together, I want the border to be around both like it is one.

Thanks
Amour22015Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PatHartmanCommented:
There is no property that will do this.  You will need to set both controls to have no border, then draw a box around both controls.

Alternatively, since this is a report, you can concatenate a string with the actual data value and bind the control to that calculated value:

Select "Customer Name: " & CustName as CalcCustName, ....
Amour22015Author Commented:
Ok, I started doing just that.  Can I associate the box to the 2 text/label? so when/if someone moves it all go together?

Thanks
Dale FyeOwner, Developing Solutions LLCCommented:
What kind of border are you talking about?  Can you provide a screen shot?

labels and controls have a BorderStyle, BorderWidth, and BorderColor properties.  Can you not use those?

If not, you could add a rectangle control with a foreground color and then place the controls on top of that rectangle.
Active Protection takes the fight to cryptojacking

While there were several headline-grabbing ransomware attacks during in 2017, another big threat started appearing at the same time that didn’t get the same coverage – illicit cryptomining.

Amour22015Author Commented:
Dale Fye
That is part of my question.  When I place the controls on top of the rectangle can I now assoc. the transparent rectangle to the controls so that if someone in design view clicks on the rectangle or control they are all grouped/assoc.?

Thanks
Nick67Commented:
You are opening an unhappy kettle of worms with this idea.
Data and controls can GROW.
When they do, such things break.
You can put a rectangle around anything.
It and the line are two of the standard controls on the control toolbar and I think on the ribbon, too.
You can put lines under, over, to the left and to the right of anything, too.

But they can grow, and then things tend to get REALLY complex quickly, because controls and sections have their heights and widths at design time, and they remain so at format time.  After Format() events, you can discover the final dimensions of things in Print() events, but they are then READ-ONLY.  You can code in the Print event to draw lines and shapes of the paper at specified locations, that you can suss out in code at that point.

It's not impossible -- it's just a painful amount of work to code and test in all possible scenarios that might break it.

You might be better off to .Visible = False the actual data controls, lengthen the label to cover the whole space and then in a Format() event change the label's caption property to be that label text & the datavalue.  however, label's do not have CanGrow so if the text was too long you'd be SOL

You could delete the label, .Visible = False the data textbox and add an unbound textbox. and set its value in a Format() event.

You could also put a very, very narrow textbox just shorter than the two controls between them with a ( I assume white) background.  This would cover the lineage you don't want to see and give the appearance of a single border.  growth screws this up, too, though.

I wouldn't try to go down this road.
It ain't fun.
Nick67Commented:
Ok, I started doing just that.  Can I associate the box to the 2 text/label? so when/if someone moves it all go together?
Not well.
Perhaps in later versions of Access than I currently use, but Access 2003 was very much unlike VB 6 in this regard.
There is Group and Ungroup, but these had some very unpredictable effects in A2010 if I recall correctly -- like throwing away your groupings each time the report was put in Design View -- and I don't think you'd want to go there.

If you ever try to move Option Groups around a report dynamically, you get to discover just how un-fun that can be.
PatHartmanCommented:
Ok, I started doing just that.  Can I associate the box to the 2 text/label? so when/if someone moves it all go together?

Open in new window

Using my concatenation suggestion, you have only a single control so there is nothing to associate.  As the others have already pointed out, drawing a rectangle around two controls is fraught with problems if the contents can grow.  Of course, you can set the control to not grow or shrink so the size won't ever change.  It depends on your data.  All in all, the concatenation solution will end up being less trouble and isn't affected by controls growing and shrinking since you have only one object that includes both label and data.  the downside of course is that you can't distinguish between the two using properties such as color or font.
Amour22015Author Commented:
Ok never mind I figured it out.

I am doing it all wrong.

I need to do this
Members
2015

and thought I had to do
Members
=Year(Now())
for current year
and I associated them together

When instead I should do:
= "Members " & (Year(Now())
and place a border around.

Maybe you can answer how I can unassociated the ones I did wrong?

Thanks.
Nick67Commented:
Maybe you can answer how I can unassociated the ones I did wrong?
You can change associations between a label and a control.
Select a label AND a new control to associate it with.
The little error-tip dropdown will appear.
Choose to change the association.

The only way I know of to break a label association without replacing it with a new association is to cut-and-paste to a new section and then back, or to delete/recreate the label.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Amour22015Author Commented:
I really messed this question up so I am giving points to everyone.  Thanks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.