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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When txtbox has expanded, possible to read txtbox new height? 1

Status
Not open for further replies.

Bresart

Programmer
Feb 14, 2007
314
ES
Hi, i have a textbox with the Autoexpand property set to yes, and depending on the height property of that textbox (if expanded or not and how much) the code must set the .top property of another textbox.

When i use Me.txtbox.Height, that value correspond to the textbox height not expanded, so it's always the same value.

Can the code catch the new textbox height when it's expanded?

Thanks in advance for any help.
 
The problem was the wrong place of code: different heights can be read in Print event but not in Format event.

Now, since Format event is first, and Print event after and in that event it's not possible to set format properties like .Top without error, is it possible to pass the height value from Print event (the unique that can read differents heights) to any other place where the .Top property can be set (in Format event)?

Thanks.
 
You can use the Print and/or Line methods of the report in the On Print event. This allows you to find out the grown height of controls and position either text or lines/boxes almost anywhere on your report.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Thanks. The problem really is to set the .Top property of another textbox after reading the new height. The .Top property can only be set in the Format event, event that passes before than Print event.
 
I understand your points. I am suggesting you make your "another textbox" invisible and use the Print method to print the "another textbox" value where ever you want.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
I tried that: the textbox (invisible) in another and previous section like a header, the inconvenient is the blank and non-equal spaces that leaves this new section between previous and next printed records.

Thanks.
 
My suggestion was to use code in the On Print event of the report section to print the value. Did you try write some code? Did you understand the suggestion?

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
I did that code:




Dim daysTop as Integer

Private Sub HeaderGroup0_Print(Cancel As Integer, PrintCount As Integer)
daysTop = 75 + (Me.Text198.Height - 150)
End Sub

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.Day1.top = daysTop
Me.Day2.top = daysTop
End Sub





It would be desireable to hide the HeaderGroup0 and not only to set the Text198 colortext to white for having the effect of hidding the control, because its blank space is in the report and it's different depending of the Text198.Height.

Thanks.
 
Assuming you have an invisible text box [txtName] that you want to always appear in the detail section 2" from the left and 3" from the top of the section. You want this position even if something above the txtName might push it down. Try code like:
Code:
Me.CurrentX = 1440 * 2
Me.CurrentY = 1440 * 3
Me.Print Me.txtName

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
It works correctly. Is there a way for control txtName keeps the format (text color, font type and size)?

Thanks.
 
The new code is:



Dim daysTop as Integer

Private Sub HeaderGroup0_Print(Cancel As Integer, PrintCount As Integer)
daysTop = 75 + (Me.Text198.Height - 150)
End Sub

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.CurrentY = daysTop
Me.Print Me.Day1
Me.CurrentY = daysTop
Me.Print Me.Day2
End Sub

 
Try something like:
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Me.FontSize = Me.Day1.FontSize
    Me.FontName = Me.Day1.FontName
    Me.ForeColor = Me.Day1.ForeColor
    Me.CurrentY = daysTop
    Me.Print Me.Day1
    Me.CurrentY = daysTop
    Me.Print Me.Day2
End Sub


Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
I haven't found between Me properties the Text Alignment property, for giving to the report the Dia1 value in that property ("center"). What would the code be for that?

Thanks.
 
There is no "center" property that I am aware of. There are probably methods using font metrics to determine the size of rendered text or whatever. This would be beyond my experience and interest ;-)

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top