• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 309
  • Last Modified:

MS access 2010

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
snhandle
Asked:
snhandle
1 Solution
 
Rgonzo1971Commented:
Hi,

Have you tried the Canshrink Property

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

Regards
0
 
snhandleAuthor Commented:
Yes I did but it is not working.
0
 
NorieCommented:
Can't you exclude the negative records in the report's underlying query?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
snhandleAuthor Commented:
I know but here I am using running sum field in the report.
0
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
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
 
clarkscottCommented:
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
 
Dale FyeCommented:
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
 
snhandleAuthor Commented:
It is not working, actually the "amount detial" is running sum amount so we do not have that column in the query.
0
 
Dale FyeCommented:
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
 
snhandleAuthor Commented:
Is there any VBA statement where I can do something about it?
0
 
Dale FyeCommented:
@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
 
snhandleAuthor Commented:
it was a good hint.
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now