Stephen Lebans RTF2 stuck

G

Guest

SQL Server 2000SP3
Access 2000 SP3 (.adp)

Stephen Lebans, I was hoping you may be willing and have the time to look
through this.

I have a landscape A4 report with:
- 1 horizontal RTF2
- 3 vertical RTF2

eg
_____________
_____1_______
| 2 | 3 | 4 |

This works fine in a form, but I need to export as snapshot viewer format so
have had to re-create the form as a report.

I set the heights of the RTF2 controls based on the size of the data, so
that 1 record = 1 page. In the case of the form, this occurs using the
onCurrent event of the form, works fine.
On the report, I used the onFromat event of the detail section.

The problem is, if the data in one of the RTF2 controls (2,3,4) is large
enough that normally it would cause the report to go to two pages, this
causes the report to got to 99999999 etc pages, neverending.
The dynamic resize of the control works, as the control is well within the
limits of the page, but I get never ending blank pages.

The really odd thing is if I (while in print preview) click on Page Setup
then click OK (not actually change anything), it sorts itself out and shows
just 1 page. So I've asked another question to see if I can set this in vba
onFormat event without the users knowledge, so its seamless. But thought I'd
check the RTF2 things with you if ok.
Sorry for the waffle, is this something you've seen before or...

Fingers crossed on my part!!

Many thanks for any help!


Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error GoTo ERR_ERROR
Dim OBJ As Object

Dim H1 As Integer ' height of box 1 contents
Dim H2 As Integer ' height of box 2 contents
Dim H3 As Integer ' height of box 3 contents
Dim H4 As Integer ' height of box 4 contents

Dim MH0 As Integer ' max height of page
Dim MH1 As Integer ' max height of box 1
Dim MH2 As Integer ' max height of box's 2-4
Dim DTH As Integer ' max height of detail section

Dim LT As Integer ' Label's top
Dim B2T As Integer ' Box's 2-4 top

H1 = 0
H2 = 0
H3 = 0
H4 = 0
MH0 = 8400
MH1 = 3200
MH2 = 5200
DTH = 10550
' make sure the detail secion is set to its MAX
Me.Report.Section(acDetail).Height = DTH

For Each OBJ In Report
If InStr(OBJ.Name, "RTF") Then ' if the name has RTF, then its an
RTF control...hopefully..
If InStr(OBJ.Name, "1") Then ' if the RTF name has a 1 then its
text box 1 and appears at the top
H1 = H1 + OBJ.rtfheight
ElseIf InStr(OBJ.Name, "2") Then ' box 2
H2 = H2 + OBJ.rtfheight
ElseIf InStr(OBJ.Name, "3") Then ' box 3
H3 = H3 + OBJ.rtfheight
ElseIf InStr(OBJ.Name, "4") Then ' box 4
H4 = H4 + OBJ.rtfheight
End If
End If
Next OBJ

' what is the largest height of the three box's as the bottom of the page
If H2 > H3 Then
H2 = H2
Else
H2 = H3
End If

If H2 > H4 Then
H2 = H2
Else
H2 = H4
End If

' if box1 bigger than its max and the largest of box's 2-4 are not then
use spare space on box 1
If H1 >= MH1 And H2 <= MH2 Then
Me.RTF_CT_TEXT_1.Height = (MH0 - H2)
Me.RTF_CT_TEXT_2.Height = H2
Me.RTF_CT_TEXT_3.Height = H2
Me.RTF_CT_TEXT_4.Height = H2

Else ' if box1 is smaller than its max size and the largest of
boxes 2-4 are bigger than max, use spare space on 2-4
If H1 <= MH1 And H2 >= MH2 Then
Me.RTF_CT_TEXT_1.Height = H1
Me.RTF_CT_TEXT_2.Height = (MH0 - H1)
Me.RTF_CT_TEXT_3.Height = (MH0 - H1)
Me.RTF_CT_TEXT_4.Height = (MH0 - H1)
Else
Me.RTF_CT_TEXT_1.Height = MH1
Me.RTF_CT_TEXT_2.Height = MH2
Me.RTF_CT_TEXT_3.Height = MH2
Me.RTF_CT_TEXT_4.Height = MH2
End If
End If
' position the box's
' The top of the box labels, and the top of the three bottom box's (2-4)
LT = (Me.RTF_CT_TEXT_1.Top + Me.RTF_CT_TEXT_1.Height + 80)
B2T = LT + 300
Me.lbl_CT_TEXT_2.Top = LT
Me.lbl_CT_TEXT_3.Top = LT
Me.lbl_CT_TEXT_4.Top = LT
Me.RTF_CT_TEXT_2.Top = B2T
Me.RTF_CT_TEXT_3.Top = B2T
Me.RTF_CT_TEXT_4.Top = B2T

Exit Sub

ERR_ERROR:
Call Errors
End Sub
 
S

Stephen Lebans

Might be simplest for you to just Email me your stripped Down ZIPPED MDB.
Last week a poster Emailed me a 50MB MDB. If it is not under 10MB I don't
want it!
My Email address is:
(e-mail address removed)
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top