Solved

Grow label height with text box height in Access report

Posted on 2008-10-30
10
1,924 Views
Last Modified: 2013-11-28
Hi

I have a report with text boxes that have the property "Can Grow" set to "Yes".  Thus, when the control source is a long memo string, the text box height increases to accomodate all of its contents.

However, I cannot find a way of making the height of the associated label increase accordingly.  This affects the presentation of the report.

Thank you.
0
Comment
Question by:ntahall
  • 5
  • 4
10 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22844360
ntahall,

You cannot do this easily.

The reason is because the assumption is that the lable needs to be "Near" the textbox, it does not really have to be the same size as the textbox.
For example, If the field is a desciption and it is 1000 charchters long and the textbox grows to 3 inches tall, the label that simply says "Description", does not really need to be 3 inches tall as well.

That being said ... If you put a solid border around the label, sometimes this is needed.

However, the size that the textbox grows is not really exposed to VBA.
For example if you do this:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    MsgBox Me.PlotSummary.Height
End Sub

The height will be thae same for all the records, but the actual textbox height will vary.

You can try this page:
http://www.lebans.com/Report.htm

Perhaps something there might help you.

JeffCoachman
0
 

Author Comment

by:ntahall
ID: 23027802
Hi Jeff

Apologies for the delay in getting back to you, we've been busy with something else.

One of my colleagues has tried your suggestion but was unable to get it to work.

I've also had a look at http://www.lebans.com/Report.htm but was unable to find something that would to the trick.  Is there are one of their utilities that you'd recommend for this problem?

Kind regards
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 23033358
ntahall,

Then use a textbox instead of a Label.

Set the Textbox ControlSource to whatever the Label caption was.

So if the Label caption was:   c98f33wrfliwehtfkurhfgihifhcicierfnierwie

Set the new Textbox ControlSource to: ="c98f33wrfliwehtfkurhfgihifhcicierfnierwie"

Then set the Cangrow Property of this new textBox to: Yes

JeffCoachman
0
 

Author Comment

by:ntahall
ID: 23077848
Hi Jeff
Thanks for that.  Will the textbox then grow with the adjacent one or will some code be required?
Nick
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 23079883
ntahall,

The textbox will grow to the height that will display all the text within it.
It cannot be set to "grow" the same amount as another control.

Besides, the "Height" of textboxes when it Grows, really does not change as far as VBA is concerned.

What effect are you trying to achieve with this system?

JeffCoachman
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

Author Comment

by:ntahall
ID: 23138218
Hi Jeff

Yes it will as I'm trying to display the label and control as a row in a table, with the background colour dependent on the risk score.

This works fine as long as everything has only 1 line of text, but as soon as it's a bigger it makes the report look awkward.

Kind regards
Nick
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 400 total points
ID: 23141072
ntahall,

There is no easy way around this because there is no property that allows Labels to Grow to the same height as the associated textbox.

You can see this link, perhaps you can use one of the technique for a possible workaround.
http://www.lebans.com/Report.htm

Another option:
Make the textbox and the Lable the same width.
Copy the textbox and set the text color (ForeColor) the same as the Back Color.
Put the textbox on the lable so that it covers it entriely.
Use the Format menu to "Send it to Back"

This will make the textbox grow"Behind" the label, acheiving the effect you are looking for.

Here is a screenshot
;-)

JeffCoachman
untitled.JPG
0
 
LVL 10

Assisted Solution

by:calpurnia
calpurnia earned 100 total points
ID: 23147357
Hi ntahall, seeing Jeff's suggestion above has made me think of  a slight variation on his idea - if you're not bothered about having a gap between the label and the control, you could set the Left Margin property of the control to a suitable value, and then place the label on top of the control.

By the way, Jeff - are you going to give us the answers to the 'Guess the name of the movie from the plot summary' quiz above?


0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 23148613
calpurnia,

"By the way, Jeff - are you going to give us the answers to the 'Guess the name of the movie from the plot summary' quiz above?"

LOL!

This is an OLD Access database table, that the training company I used to work for used.
If you open up many of my "Samples", you will see that I use it over and over again.
;-)
Jeff

BTW, for the record, here are the titles:
untitled.JPG
0
 

Author Closing Comment

by:ntahall
ID: 31511669
Thanks for this.  The combination of solutions works, although I could have done with the gap between the label and the control.
Kind regards
Nick
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MS Access 2016 Debugging 7 42
DSum for Access 6 43
sort Time by AM and PM in query 2 18
Search Form not Querying 2 10
This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now