View Full Version : description in report not sizing correctly


avwtech
12-28-2004, 06:54 AM
Ok. I've got a report that is generated from a value called COI2. This report is displaying records row after row. Each row is indented based on the number of periods in its title(for instance: A1.1 is a root with A1.1.1 indented and A1.2 falling directly under A1.1). This works fine and everything lines up. This document is for the Dept. of Navy so everything must follow a certain format. On most of my reports my coding works fine, but on some of the larger ones I receive a "control too large" error. In efforts to fix this error, I made the commented out code dictating the size of the details control. This code however only utilizes 60% of a landscape report. I tried "can grow" but it seems to only be working vertically and not horizontally. I need to make a way for my descriptions to fill the page width to the right hand side without jepordizing their formatted position on the left hand side. Let me know what yall think. Any help towards solving this problem will be much appreciated. Thanks a lot.

Dave


----- -CODE- -----
Dim COI2 As String
COI2 = Reports("COI2outline").Section("Detail").Controls("COI2").Value
Dim numPeriods As Integer, periodplace As Integer
numPeriods = 0
periodplace = 1

Do While Not InStr(periodplace, CStr(COI2), ".") = 0
periodplace = InStr(periodplace, COI2, ".") + 1
numPeriods = numPeriods + 1
Loop


' Size = (8 * 1440) - (700 * CInt(numPeriods))
' Do Until (Size + 900 + 700 * numPeriods) < (7.5 * 1440 + 80)
' Size = Size - 100
' Loop
' Reports("COI2outline").Section("Detail").Controls("Description").Width = Size
Reports("COI2outline").Section("Detail").Controls("COI2").Left = 200 + 600 * numPeriods
Reports("COI2outline").Section("Detail").Controls("Description").Left = 900 + 600 * numPeriods ' ERROR debugs to this line of code numPeriods=4

If numPeriods < 2 Then
Reports("COI2outline").Section("Detail").Controls("COI2").fontsize = 10
Reports("COI2outline").Section("Detail").Controls("Description").fontsize = 10
Else
Reports("COI2outline").Section("Detail").Controls("COI2").fontsize = 8
Reports("COI2outline").Section("Detail").Controls("Description").fontsize = 8
End If

llkhoutx
12-28-2004, 02:17 PM
CanGrow only works vertically. You have to compute the horizontal size if it's to grow. Line by line will be a problem on the OnFormat event. Why not make the horizontal size always the maximum width?

john471
12-28-2004, 07:14 PM
Maybe something along these lines might work....
I only adjusted the position of the description field... but you'll get the idea.


Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim COI2 As String
Dim numPeriods As Integer
Dim periodplace As Integer
Dim offset As Integer

COI2 = Me.COI2
numPeriods = 0
periodplace = 1

'You need to put it/them in the starting position for each detail instance
'otherwise they just keep moving further and further to the right, and getting narrower and narrower!

'Possibly making larger, therefore... Left property first, then width
'You could do some extra coding to determine & store the starting values
'and re-use those - but I'll leave that for you to do if you want.

Me.Description.Left = 870 'put your own value in here
Me.Description.Width = 4700 'put your own value in here too


Do While Not InStr(periodplace, CStr(COI2), ".") = 0
periodplace = InStr(periodplace, COI2, ".") + 1
numPeriods = numPeriods + 1
Loop

offset = (numPeriods - 1) * 144 'one tenth of an inch per period in excess of one.

'Possibly moving to the right, therefore... Width property first, then left
Me.Description.Width = Me.Description.Width - offset
Me.Description.Left = Me.Description.Left + offset

If numPeriods < 2 Then
Me.COI2.FontSize = 10
Me.Description.FontSize = 10
Else
Me.COI2.FontSize = 8
Me.Description.FontSize = 8
End If
End Sub



HTH

Regards

John

avwtech
12-29-2004, 07:23 AM
Thanks a lot John. Code works awesome and I won't have to spend another day looking at how to fix a little formatting error. Phew. Thanks.

- Dave

john471
12-29-2004, 03:53 PM
You are welcome. Glad it helped.