Solved

Access Report Format

Posted on 2015-02-10
13
62 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 50

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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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 36

Expert Comment

by:PatHartman
ID: 40604007
Gus,
Do you know if this technique would work in an .accde?
0
 
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 36

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

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.

Question has a verified solution.

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

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

829 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