Re: Bug in Access 2002 Reports

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Jesse Aviles (monk_at_coqui.net)
Date: 05/20/04


Date: Thu, 20 May 2004 16:51:02 -0700

Mr. Lebans:

I have two fields that contain a number that specifies a depth. I want two have a report that makes the detail section taller or smaller depending on the difference between these two fields. This will give the report a feeling of being "to scale", when you look at it you can see there are smaller, larger or equal intervals. For example:
     Top Bottom Difference
     0 2 2
     2 6 4
     6 8 2
Looking at the above, you can see that two interval are equal and one interval is larger. I want this difference to be observed visually ally in the report, as follows:
     Top Bottom ------------------------------------------------------|
     0 |
                                                                                              |
                2 ------------------------------------------------------------|
     2 |
                                                                                              |
                                                                                              |
                                                                                              |
                                                                                              |
               6--------------------------------------------------------------|
     6 |
                                                                                              |
               8--------------------------------------------------------------|
     
When you look at the code, you will see an equation that will take care of performing the substraction to determine the difference between the two fields. The result of the substraction is the number that is then provided to the Detail.Height property to set the Height of the detail section as every record is formatted. First problem comes when only the lower part of the code is used (enclosed in an If...Then...Else statement). Access will format the section but it will remember the last placement of the controls. This behavior makes the section taller and not smaller (it doesnt matter that the code is instructing Access to make the section smaller). When Access prints the report, the print out comes the same way as on screen but the behaviour (placement of controls) is faulty. That is why the first half of the code is important. It places the controls at the top of the section every time the section is formatted forcing Access to use the behavior intended in the code. Access complies and formats the
 section as I intend making the display look "to scale". Problem is the print out will not show the controls placed as in the screen. I hope this makes the problem clearer. Thank you.

     ----- Stephen Lebans wrote: -----
     
     Without even trying to figure out what you are trying to accomplish,
     with A2K or higher you can set the Height of the Detail section directly
     in the section's Format event.
     Me.Section(acDetail).Height = whatever
     
     --
     
     HTH
     Stephen Lebans
     http://www.lebans.com
     Access Code, Tips and Tricks
     Please respond only to the newsgroups so everyone can benefit.
     
     
     "notbitmonk" <anonymous@discussions.microsoft.com> wrote in message
     news:09586AC6-F02E-494B-8AB6-403A5570A519@microsoft.com...
> I have a procedure attached to the format event of the detail section
     of a report. The code works great. I can see the report with the layout
     that I want (code in the format events takes care of positioning field
     boxes and creating a "scaled" report"). Problem is that when I send the
     report to print, the printout does not has any of the format that I see
     on the screen (I print it to a Lexmark X1550 and to PDF). The
     formatting is lost even if I export to snapshot. If you look at the
     code you will see that is divided in two sections. The first section
     positions the fields at the top of the detail section. This is done
     because Access wil "remember" the last height of the section and
     continue using it until a larger height is provided, it doesnt matter
     that the code is giving instructions to make the section smaller. If
     the first part of the code is not included, the report will come out
     "half-scaled", meaning that it will make the section bigger and not
     smaller. Also, when the report is printed, I start getting error the
     the control is too big for the section but I dont see any extra space
     and the report will print. If I try attaching the code to print event,
     I just get a bunch of errors because properties are not available at
     Print time. Thank for any help. Here is the code:
>> Option Compare Database
> Option Explicit
> Dim intDepth As Integer
>> Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
> 'Scales detail section to fit boring log
>> On Error GoTo ErrorHandler
>> If IsNull(intDepth) Then
> intDepth = 0
> End If
> 'Position controls at the top to prevent misplacement
> DepthTop.Top = 0
> DepthBottom.Top = 0
> USCS.Top = 0
> Description.Top = 0
> SampleSelected.Top = 0
> GWObserved.Top = 0
> timeHour.Top = 0
> sngResults.Top = 0
> sngRecovery.Top = 0
> Detail.Height = 300
> Line41.Height = 300
> Line42.Height = 300
>> If (Nz(DepthBottom) - intDepth) > 1 Then
> Detail.Height = (DepthBottom - intDepth) * 300
> intDepth = DepthBottom
> DepthTop.Top = 0
> DepthBottom.Top = Detail.Height - 300
> USCS.Top = Detail.Height - 300
> Description.Top = Detail.Height - 300
> SampleSelected.Top = Detail.Height - 300
> GWObserved.Top = Detail.Height - 300
> timeHour.Top = Detail.Height - 300
> sngResults.Top = Detail.Height - 300
> sngRecovery.Top = Detail.Height - 300
> Line41.Height = Detail.Height
> Line42.Height = Detail.Height
> End If
>> ExitHandler:
> Exit Sub
>> ErrorHandler:
> MsgBox "Error: " & Err.Number & vbNewLine _
>& "Description: " & Err.Description, vbMsgBoxHelpButton, "Error
     during
> format", Err.HelpFile, Err.HelpContext
>> GoTo ExitHandler
>> End Sub
>> --
> Jesse Avilés
> monk@coqui.net
>


Quantcast