Solved

Access Report Format

Posted on 2015-02-10
13
52 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 48

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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

743 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

12 Experts available now in Live!

Get 1:1 Help Now