Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to ensure all textboxes have same height? 1

Status
Not open for further replies.

gohym

Technical User
Jul 22, 2003
36
SG
Hi,

Appreciate any help that you can give here... Thanks.

I have this report with 5 textboxes. Each of them is set to "can grow" = true. However, it is also prefered that all the text boxes have the same height. I have the following code... but it does not seem to work.


Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

'Determine the tallest textbox
Dim intMaxHt As Integer

intMaxHt = 0

For i = 0 To Me.Count - 1
    If TypeOf Me(i) Is TextBox Then
        If Me(i).Height > intMaxHt Then
            intMaxHt = Me(i).Height
        End If
    End If
Next

Me!CSIID.Height = intMaxHt
Me!Attribute.Height = intMaxHt
Me!AuditMethod.Height = intMaxHt
Me!RatingOption.Height = intMaxHt
Me!RatingBox.Height = intMaxHt


I am guessing that during runtime of the code, the "can grow" effect takes place AFTER the code. Thus, the "can grow" effect overwrites the effect of the code... just a guess... am I right? How do I get the code to work??? Thanks!
 
You would want to grab the heights in the On Print event, not the On Format event. Then, rather than attempting to set the height of your other controls which I don't think is possible in most versions of Access, you can use the Line method to draw rectangles around your text boxes.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Hi dhookom,

Thanks for the reply.

Can you elaborate on the Line method? to be frank I'm not that proficient with all these programming stuff... Thanks!

 
Taking your code and moving it to the On Print event(caution untested):
Code:
'Determine the tallest textbox
Dim intMaxHt As Integer
intMaxHt = 0
For i = 0 To Me.Count - 1
    If TypeOf Me(i) Is TextBox Then
        If Me(i).Height > intMaxHt Then
            intMaxHt = Me(i).Height
        End If
    End If
Next
Me.Line (Me.CSSID.Left, Me.CDDID.Top)- _
    Step(Me.CSSID.Width, intMaxHt),,B
Me.Line (Me.Attribute.Left, Me.Attribute.Top)- _
    Step(Me.Attribute.Width, intMaxHt),,B
Me.Line (Me.AuditMethod.Left, Me.AuditMethod.Top)- _
    Step(Me.AuditMethod.Width, intMaxHt),,B
Me.Line (Me.RatingOption.Left, Me.RatingOption.Top)- _
    Step(Me.RatingOption.Width, intMaxHt),,B
Me.Line (Me.RatingBox.Left, Me.RatingBox.Top)- _
    Step(Me.RatingBox.Width, intMaxHt),,B
This should draw boxes around your controls dynamically so you can remove any border.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Hey it worked!

May still need a bit of adjustments, as the text is a bit close to the box, but let me solve that part myself... Thanks!!
 
Glad to here you have it mostly working. This is partially due to a well-asked question with your code and requirements. I wish all questions were so clear.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
That's because I read the FAQ on how to get great answers! Cheers... see you around.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top