Solved

Grow label height with text box height in Access report

Posted on 2008-10-30
10
2,083 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

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
 

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

717 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