Solved

MS access 2010

Posted on 2013-01-20
12
263 Views
Last Modified: 2013-02-23
I have report in MS access where I  wrote script to show me only negative records and do not show me the positive records. I wrote the statement below.
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.AmountDetail < 0 Then
    Me.Text9.Visible = True
    Me.Date.Visible = True
Else
    Me.Text9.Visible = False
    Me.Date.Visible = False
End If
End Sub

It does work and only show negative records but it shows blank lines for positive records. I do want to shrink the report and do not want empty spaces showing on my report. I already choose the "Can grow" and Can shrink properties to yes but it is not working. Any idea to get rid of the blank lines to now show on the report.
0
Comment
Question by:snhandle
12 Comments
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 38799991
Hi,

Have you tried the Canshrink Property

http://msdn.microsoft.com/en-us/library/office/aa224008(v=office.11).aspx

Regards
0
 

Author Comment

by:snhandle
ID: 38799993
Yes I did but it is not working.
0
 
LVL 33

Expert Comment

by:Norie
ID: 38800002
Can't you exclude the negative records in the report's underlying query?
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

Author Comment

by:snhandle
ID: 38800008
I know but here I am using running sum field in the report.
0
 
LVL 57
ID: 38800044
1. Make sure your running that code in the OnFormat event

2. Make sure you have can shrink set for the controls and for the section.

3. Make sure there is nothing stopping the section from shrinking; other controls, lines, etc. all way across the page.

If that gets you no where, post a screen shot of the report design.

 Jim.
0
 
LVL 20

Expert Comment

by:clarkscott
ID: 38800636
In your source query, eliminate these "empty" or null records.  For instance, if the DATE field is expected, simply add  WHERE DATE IS NOT NULL and then sum your records.  PS.  Blank rows are legitimate rows and "shrinking" won't work.  You must eliminate them from the source.

Scott C
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 38800949
How about simply setting the reports Filter Property to:

[AmountDetail]< 0

You could do this using the WHERE argument of the OpenReport method, or by simply changing the query that is the RecordSource for your report.
0
 

Author Comment

by:snhandle
ID: 38801957
It is not working, actually the "amount detial" is running sum amount so we do not have that column in the query.
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 38803328
You could loop through the controls in the details section, in the Format event, and change the height of all the controls in that section.  With the sections, "Can Shrink" set to Yes, if the controls are 0 height, the section should shrink as well.
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

    Dim dblHeight As Double
    Dim ctrl As Control
    
    dblHeight = IIf(Me.txtDetailAmount < 0, 0, 0.2083) * 1400
    
    For Each ctrl In Me.Section(acDetail).Controls

        ctrl.Height = dblHeight

    Next
    Me.Section(acDetail).Height = dblHeight + (dblHeight * 0.125)
    
End Sub

Open in new window

In the attached sample, I use txtDetailAmount Mod 4 = 0, since I don't have any negative numbers, as you can see the rows for 7 and 8 are missing from the output.  But you will probably have to do this in PrintPreview mode, as the Detail Format event will not fire in Report View.
DetailAmount.accdb
0
 

Author Comment

by:snhandle
ID: 38803444
Is there any VBA statement where I can do something about it?
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 38803499
@snhandle

"Is there any VBA statement where I can do something about it? "

Who are you replying to, and which message.  If you want to have an effective thread, you need to indicate who you are replying to (and ideally which post, by #) when you reply like this.

Did you take a look at the sample database I provided?
0
 

Author Closing Comment

by:snhandle
ID: 38922546
it was a good hint.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question