Link to home
Start Free TrialLog in
Avatar of Karen Schaefer
Karen SchaeferFlag for United States of America

asked on

Display # of Emp in a Column Report displayed in footer of report

I have created a report that uses columns for an ORG chart report.  I need to display the total number of employees within each column.  How do I incorporated this value so that it is displayed at the bottom of the report and not at the floating bottom of the column.

I also need to include a total of employees, broken down by the type of employee - ie a legend. to also be displayed on the bottom of the report.

Note: I have tried various approaches by including the count (ie.  Count(Empl#) places in the Manager footer - this gave me the floating value depending on the height of the column values.  Then I tried using this field as a hidden field and placing a text field in the Report footer that references that hidden field - but that failed.

Also tried using a subreport but I was unable to get the report to line up with the Manager's column in the main report.

Looking for any suggestions.User generated image - sample from the original spreadsheet - which I am attempting to create in an Access Report.
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

<<How do I incorporated this value so that it is displayed at the bottom of the report and not at the floating bottom of the column.>>

 I would use the page/report footer as appropriate and keep your own counts.

In the reports module at the top, dim variables to keep the totals.

In the page/report header OnFormat event, init those variables to 0.

In the detail section, add to those variables in the OnFormat event doing:

 If FormatCount = 1 then
     ' Add to variables.  Use the left property to determine the column your in.
End If

In the page/report footer, push the value of your variables into unbound text controls in the OnFormat event.

 Do this with one total first to get it working, then add your other totals as needed (maybe use an array).

Jim.
Avatar of Karen Schaefer

ASKER

for some reason my report now has 3 footers for the same field, how do I remove the unused footers.  see attachedUser generated image
I may need a little more to help me get started:

<<In the reports module at the top, dim variables to keep the totals.

In the page/report header OnFormat event, init those variables to 0.

In the detail section, add to those variables in the OnFormat event doing:

 If FormatCount = 1 then
     ' Add to variables.  Use the left property to determine the column your in.
End If

In the page/report footer, push the value of your variables into unbound text controls in the OnFormat event.>>

Option Compare Database
Option Explicit

Public nMgrCt As Long

Private Sub MgrNameFooter_Print(Cancel As Integer, PrintCount As Integer)
Dim intGetVal As Integer
intGetVal = Me.Section(2).NewRowOrCol


End Sub

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

Set nMgrCt = 0

End Sub

Open in new window

K
ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
BTW, you should pickup a copy of the Access Developers Handbook published by Sybex.  Tons of code in there, one of which is a class object to handle app the prtMip chores.  Probably could have saved a ton of time with this if you had had it.

 It's great for when you get into odd-ball stuff like this.

Jim.
when I attempt to remove the misc. footers it crashes my system, so I may have to start over with my back up copy of the report.

K
Option Compare Database
Option Explicit

Public nMgrCt(3) As Long

Won't compile - get Constants, Fixed-length strings, arrays, user-defined types & declare statement not allowed as Public members of object modules.
by the way I do have a old version 2000 of the book you mentioned, it wasn't much help.  I am so use to looking things up on the web that I forget to check the actual books.

k
<<Public nMgrCt(3) As Long>>

 Sorry, that should be:

 Dim nMgrCt(3) as Long

Jim.
see error msg
User generated image
My latest attempt - please review, I am only getting the value of Zero to be displayed.

thanks,
K
OrgChartSample.zip
Working on it...

Jim.
OK, your all set.  Totals are working and I got rid of that orphand header on page 2 (totalling needed to be done differently because of that and that your doing columns).

It was caused by the fact that the column break was set for after the footer and that was forcing the page break.

I changed that to none and set the header to BeforeSection. You don't get a blank column because it knows it can't back up on the first page/first column.

Spacing on the column totals needs to be adjusted yet.

Jim.
OrgChartSample.zip
Thanks Jim for all your hard work it looks great, one minor issue - the number fields in the footer is there a way to automate the number of fields depending on the number of columns - since my column count will change depending on the Unit chief's org size.

Karen
Karen,

  In the OnFormat of the page footer, look at the totals in the array.  If the total is zero, set the corresponding controls visible property to false.

Jim.
Actually, do a loop on the array and do:

For intK = 1 to 9
   If nMgrCt(intK)>0 then
      <control>.visible = True
Else
     <control>.visible = False
End If
Next intK

  That way it will be correct for each page.

  The controls are named sequentially, so you can use the format Report!("name" & intK).Visible =

(don't rememeber the control names off-hand and I already deleted all your stuff from here).

Jim.
whats wrong wtiht this syntax

       (Reports![Report1]![txtEmpCt] " & intK.Visible) = True"
Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As Integer)
Dim intk As Integer

For intk = 1 To 11
    If nMgrCt(intk) > 0 Then
       Reports![Report1]![txtEmpCt]  " & intK.Visible = True"
    Else
       txtEmpCt1 " & intK.Visible = false"
    End If
Next intk
Report("txtEmpCt" & intK).Visible  = True

Jim.
My current code with your recommendation does not return any values - they are not visible.

Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As Integer)
Dim intk As Integer

    For intk = 1 To 11
        If nMgrCt(intk) < 0 Then
            Report("txtEmpCt" & intk).Visible = False
        Else
            Report("txtEmpCt" & intk).Visible = True
        End If
    Next intk

I tried it with both >0 and < 0 - tried switching the order of the true/false.

I verified that the fields do exists on the report - I added the additional 2 fields.
OrgChartSample.zip
For intk = 1 To 11
        If nMgrCt(intk) = 0 Then
            Report("txtEmpCt" & intk).Visible = False
        Else
            Report("txtEmpCt" & intk).Visible = True
        End If
    Next intk

Jim.
Jim

Ok after the first pass the intk value = 1, but it still wants to return visible =false

Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As Integer)
Dim intk As Integer
    For intk = 1 To 11
        If nMgrCt(intk) = 0 Then
            Report("txtEmpCt" & intk).Visible = False
        Else
            Report("txtEmpCt" & intk).Visible = True
        End If
    Next intk

End Sub
User generated image
All bets are off...the last upload you have contains the original report, which has all the funky footers in it.

That report was corrupt.   I rebuilt the whole thing from scratch and called it report1 in my upload.

That's what you need to be using.

Jim.
This BTW:

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

  Dim intk As Integer

  For intk = 1 To 9
    If nMgrCt(intk) = 0 Then
      Report("txtEmpCt" & intk).Visible = False
    Else
      Report("txtEmpCt" & intk).Visible = True
      Report("txtEmpCt" & intk) = nMgrCt(intk)
    End If
  Next intk

End Sub

Is the final code I used and it works fine here.

Jim.
Please resend the correct attachment, Thanks for all you efforts.

Karen
Here's a good one...it's Report1 in the attached zip.

Jim.
OrgChartSample-new.zip
sorry, but your version does not display multiple columns also I need a total of up to 11 fields for the footer for the employee count.

K
Yes it does, but I left the filter in from when I was testing the column total blanking.  Open up report1 and set the filteron to no and blank out the filter.

Also, your original report only had 9 columns in it.  With that said, there's nothing stopping you for squeezing in a couple of more other then layout.

Jim.