469,072 Members | 1,844 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,072 developers. It's quick & easy.

Increase line length if a field on a report grows

I have created a report that looks like a spreadsheet. The only problem is that when one of the cell grows (cangrow property is yes) then the lines beside them are not long enough. I tried this code in the on format event of the form detail section

Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  3. Me.Line96.Height = Me.description.Height
  4. Me.Line95.Height = Me.description.Height
  5. Me.Line94.Height = Me.description.Height
  6. Me.Line93.Height = Me.description.Height
  7. Me.Line92.Height = Me.description.Height
  8. Me.Line91.Height = Me.description.Height
  9. Me.Line90.Height = Me.description.Height
  10. Me.Line109.Height = Me.description.Height
  12. End Sub
But nothing changed. There will be multiple rows printing out on this report. Is there anyway to see how much the cell grows, or (through code) if the cell is going to grow, and if yes by how much. Then I could just set the height of the lines first.....maybe.

I have only made the one field (description) able to grow, and the field walls are transparent so that the height will only be decided by the sigle field.

Any help will be greatly appreciated.
Mar 3 '09 #1
3 4113
8,800 Expert 8TB
The following code will dynamically create a Vertical Line of any Width you so desire, which will be of the same Height of a Control on a Report whose CanGrow and CanShrink Properties are set to Yes. The code must reside in the Print Event of either the Detail Section or a Footer Section. In this demo, I generated a Vertical Line directly to the Left of a Description Control within a Report's Detail Section. The Line will dynamically grow to accommodate varying Heights of the Description Control. In this case, a Picture is worth 1,000 words, so download the Attachment and see what is going on. If you have any questions, please feel free to ask.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
  2. Dim sngLineTop As Single
  3. Dim sngLineLeft As Single
  4. Dim sngLineWidth As Single
  5. Dim sngLineHeight As Single
  7. Const conTWIPS = 1
  8. Const conSOLID = 0
  10. Me.ScaleMode = conTWIPS
  11. Me.DrawStyle = conSOLID
  13. 'Set the Line coordinates
  14. sngLineTop = Me![Description].Top
  15. sngLineLeft = (Me![Description].Left - 50)
  16. sngLineWidth = 25   'Width of Line
  18. With Me![Description]
  19.   sngLineHeight = .Height
  20. End With
  22. 'Now, draw the Line with the Box Fill Option
  23. Me.Line (sngLineLeft, sngLineTop)-Step(sngLineWidth, sngLineHeight), , BF
  24. End Sub
Mar 4 '09 #2
Thanks ADezzi,

I modified the code like this
Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
  3. Const conTWIPS = 1
  4. Const conSOLID = 0
  6. Me.ScaleMode = conTWIPS
  7. Me.DrawStyle = conSOLID
  9. Me.Line ((Me![LineItem].Left - 10), Me![LineItem].Top)-Step(3, Me![description].Height), , BF
  10. Me.Line ((Me![LineQty].Left - 10), Me![LineQty].Top)-Step(3, Me![description].Height), , BF
  11. Me.Line ((Me![Text111].Left - 10), Me![Text111].Top)-Step(3, Me![description].Height), , BF
  12. Me.Line ((Me![description].Left - 10), Me![description].Top)-Step(3, Me![description].Height), , BF
  13. Me.Line ((Me![SerialNum].Left - 10), Me![SerialNum].Top)-Step(3, Me![description].Height), , BF
  14. Me.Line ((Me![WorkOrderNumber].Left - 10), Me![WorkOrderNumber].Top)-Step(3, Me![description].Height), , BF
  15. Me.Line ((Me![InvoiceNo].Left - 10), Me![InvoiceNo].Top)-Step(3, Me![description].Height), , BF
  16. Me.Line ((Me![temp].Left - 10), Me![temp].Top)-Step(3, Me![description].Height), , BF
  17. End Sub
And it worked great. Thanks for the reply...... Do you really just sit around and wirte experimental databases just to upload...., crazy if you do, but it is very much appreciated.
Mar 4 '09 #3
8,800 Expert 8TB
Glad it worked out for you.
Mar 5 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by jamait | last post: by
6 posts views Thread by Darren Dale | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.