By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,551 Members | 2,622 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,551 IT Pros & Developers. It's quick & easy.

Increase line length if a field on a report grows

P: 74
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)
  2.  
  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
  11.  
  12. End Sub
  13.  
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
Share this Question
Share on Google+
3 Replies


ADezii
Expert 5K+
P: 8,638
@kstevens
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
  6.  
  7. Const conTWIPS = 1
  8. Const conSOLID = 0
  9.  
  10. Me.ScaleMode = conTWIPS
  11. Me.DrawStyle = conSOLID
  12.  
  13. 'Set the Line coordinates
  14. sngLineTop = Me![Description].Top
  15. sngLineLeft = (Me![Description].Left - 50)
  16. sngLineWidth = 25   'Width of Line
  17.  
  18. With Me![Description]
  19.   sngLineHeight = .Height
  20. End With
  21.  
  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

P: 74
Thanks ADezzi,

I modified the code like this
Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
  2.  
  3. Const conTWIPS = 1
  4. Const conSOLID = 0
  5.  
  6. Me.ScaleMode = conTWIPS
  7. Me.DrawStyle = conSOLID
  8.  
  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
  18.  
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

ADezii
Expert 5K+
P: 8,638
@kstevens
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.