Solved

Access Report Format

Posted on 2015-02-10
13
68 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +3
13 Comments
 
LVL 51

Expert Comment

by:Rgonzo1971
ID: 40602530
HI,

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

Regards
0
 
LVL 58
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 58
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 50

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 38

Expert Comment

by:PatHartman
ID: 40604007
Gus,
Do you know if this technique would work in an .accde?
0
 
LVL 50

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 58
ID: 40604166
Nice solution!

Jim.
0
 
LVL 29

Expert Comment

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

Ron
0
 
LVL 58
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 38

Expert Comment

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

Author Closing Comment

by:jb702
ID: 41228306
Thank you
0
 
LVL 50

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
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.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

717 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