Which "On" event do I use?

Chrisopia

Registered User.
Local time
Today, 04:44
Joined
Jul 18, 2008
Messages
279
At the moment I am playing with verticle lines, although it will help with future things...

I have scoured the internet and found many different ways of doing 1 single task,
I need to simply resize my verticle lines in print preview. 1 main issue is the details section has a sub report which the lines need to extend beyond.

Now I have the code, but place it in the On Page event of the report and I get error "Cannot adjust property: Height in print preview mode"

Another forum suggested the "On Format" event of the Detail section, whilst it worked for the first record, using the Me.Height to encapsulate even the subform... but the following records are ignored and the height is applied to all, but not relative to the record height.

For example if the first records sub report has 3 entries, it will make the height of all records the same, regardless if the next has 2 or 4 or no records at all.

None of the other events seem to apply for dynamic resizing of height etc...

Hope you can help, any advice is appreciated.

Code:
Dim LHeight As String
LHeight = Me.Height

Line39.Height = LHeight
Line38.Height = LHeight
Line37.Height = LHeight
Line36.Height = LHeight
Line35.Height = LHeight
Line34.Height = LHeight
Line33.Height = LHeight
 
You would put your code in the On FORMAT event of the section that the controls are in.
 
The On Format event works, but it's only taking the height of the first record, and ignoring the rest, but is still applying the height.

For example, I put feed the height into a text box control to find the height. The first record is 452, the subreport has 2 records. The second record's subreport has only 1 record, yet the height still says 452. The third record has no subreport, and it still says the height is 452.

It's nothing to do with space on the report because without applying the height of the line code, the spaces to resize.
 
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
'object.Line [[Step](x1, y1)] - [Step](x2, y2)[, [color][, B[F]]]

Me.Line (0, 0)-(0, Me.Height), 0
Me.Line (Me.Width, 0)-(Me.Width, Me.Height), 0
Me.Line (Line35.Left, 0)-(Line35.Left, Me.Height), 0
Me.Line (Line36.Left, 0)-(Line36.Left, Me.Height), 0
Me.Line (Line37.Left, 0)-(Line37.Left, Me.Height), 0
Me.Line (Line38.Left, 0)-(Line38.Left, Me.Height), 0
Me.Line (Line39.Left, 0)-(Line39.Left, Me.Height), 0

End Sub

I've lost the website I found this on, but it has solved my issue.
I've drawn the lines using code instead of physical lines. However I spent so long perfectly spacing them out, I just used the Left property of each line to position them.

I believe this method is the tidiest, easiest way to place lines dynamically.
The comment line explains the code, an apparently corrected version to that on the Microsoft help site.
It controls both the width and height in Twips so be sure to convert *1440 for inches and 567 for cm.

This code can only be used in the Print event, as sizes can changed between formatting and printing.
 

Users who are viewing this thread

Back
Top Bottom