Solved

Grow label height with text box height in Access report

Posted on 2008-10-30
10
1,893 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

762 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

19 Experts available now in Live!

Get 1:1 Help Now