Solved

Access Report Format

Posted on 2015-02-10
13
55 Views
Last Modified: 2016-02-11
I am curious if anyone know how to format the this report so the values in the amount column show at the bottom of the field and not the top of the field. See below for example.
Example.pdf
0
Comment
Question by:jb702
  • 4
  • 3
  • 2
  • +3
13 Comments
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 40602530
HI,

You could adjust the top margin of your field to push the text down

Regards
0
 
LVL 57
ID: 40603011
That's going to be a tough one.   The problem is that any control that grows along with the section height is not available until the OnPrint event, at which point it's too late to change the formatting.

If you can live with it, I would suggest creating an additional group for the total of the line, leaving the description in the detail.

It would then look like this:

This is my
description, which has
grown to three lines
                Service charge.............................................................................. $123.45

"Service charge..........." and the total being two controls in the group footer.

If you can't live with that and it must be on the same line as the last line of the description, then the only other option is to do it as one control and format the text yourself, which includes spacing and the total.

So:
="This is my" & vbCRLF & "description, which has" & vbCrLf & "grown to three lines" & Space$(x) & Format$(Me.LineTotal,"Currency")

'x' for the spacing you'd need to figure out based on the last line of the description that your formatting and the font size.

 Personally, I'd go for the grouping.  Will always format nice.


Jim.
0
 
LVL 57
ID: 40603021
And actually, there is one other option: in the OnFormat event, if you can calculate how many lines the description will push down, then you can force the total with line feeds:

Me.TextTotal = vbCRLF & vbCRLF & VBCRLF & Format$([LineTotal],"Currency"


Jim.
0
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 40603631
A bit tough ...

Print each record twice.
First print is used to measure the height of the expandable textbox. Then cancelled.
Second print set the height of the expandable textbox and moves the fixed height textbox to align with the bottom of the expandable textbox.

Set the CanGrow/CanShrink properties for the controls:

DetailSection: No/No
Expandable textbox: Yes/No
FixedHeight textbox: Yes/Yes

Insert this code:
Option Compare Database
Option Explicit

Private DefaultHeight   As Long
Private CurrentHeight   As Long

Private Sub DetailSection_Format(Cancel As Integer, FormatCount As Integer)

    Dim Height          As Long
    
    If CurrentHeight = 0 Then
        Height = DefaultHeight
        Me.NextRecord = False
    Else
        Height = CurrentHeight
    End If
    Me!ExpandTextbox.Height = Height
    Me.Section(acDetail).Height = Height
    Me!FixedHeightTextbox.Top = Height - DefaultHeight

End Sub

Private Sub DetailSection_Print(Cancel As Integer, PrintCount As Integer)

    If CurrentHeight = 0 Then
        CurrentHeight = Me!ExpandTextbox.Height
        Me.PrintSection = False
    Else
        Me.MoveLayout = False
        CurrentHeight = 0
    End If

End Sub

Private Sub Report_Open(Cancel As Integer)

    DefaultHeight = Me!FixedHeightTextbox.Height
    
End Sub

Open in new window

Report test/gustav
1
 

Author Comment

by:jb702
ID: 40603664
i have gone with the grouping method mentioned but i like Gustav's version better. I will add the code and see how it works.

thank you
0
 
LVL 34

Expert Comment

by:PatHartman
ID: 40604007
Gus,
Do you know if this technique would work in an .accde?
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 49

Expert Comment

by:Gustav Brock
ID: 40604096
Good question.
So I tried and it does. Probably because the report isn't opened in designview.

/gustav
0
 
LVL 57
ID: 40604166
Nice solution!

Jim.
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 40604263
Nice job, Gustav.  :-)

Ron
0
 
LVL 57
ID: 40604304
I was almost there myself this morning thinking about how I might make it retreat up the page, but the retreat event occurs before OnPrint, so I didn't think it was possible.

Didn't occur to me though to cancel the print event and not move to the next record or layout!

 I love those properties too and not many use them.   It's amazing what you can do with the report engine.  Here's another slick use of them and something not many realize you can do, which is address the entire page right at the start in the page header:

http://www.experts-exchange.com/Database/MS_Access/A_8911-How-to-underlay-a-section-in-Microsoft-Access-Reports.html

Jim.
0
 
LVL 34

Expert Comment

by:PatHartman
ID: 40604318
Thanks Gus - a useful technique.
0
 

Author Closing Comment

by:jb702
ID: 41228306
Thank you
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 41232544
You are welcome!

/gustav
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now