Avatar of Karen Schaefer
Karen Schaefer
Flag 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.1 - sample from the original spreadsheet - which I am attempting to create in an Access Report.
Microsoft DevelopmentMicrosoft Access

Avatar of undefined
Last Comment
Jim Dettman (EE MVE)

8/22/2022 - Mon
Jim Dettman (EE MVE)

<<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.
Karen Schaefer

ASKER
for some reason my report now has 3 footers for the same field, how do I remove the unused footers.  see attachedt
Karen Schaefer

ASKER
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
Your help has saved me hundreds of hours of internet surfing.
fblack61
ASKER CERTIFIED SOLUTION
Jim Dettman (EE MVE)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Jim Dettman (EE MVE)

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.
Karen Schaefer

ASKER
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
Karen Schaefer

ASKER
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.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Karen Schaefer

ASKER
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
Jim Dettman (EE MVE)

<<Public nMgrCt(3) As Long>>

 Sorry, that should be:

 Dim nMgrCt(3) as Long

Jim.
Karen Schaefer

ASKER
see error msg
ts
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Karen Schaefer

ASKER
sample err msg
Karen Schaefer

ASKER
My latest attempt - please review, I am only getting the value of Zero to be displayed.

thanks,
K
OrgChartSample.zip
Jim Dettman (EE MVE)

Working on it...

Jim.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Jim Dettman (EE MVE)

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
Karen Schaefer

ASKER
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
Jim Dettman (EE MVE)

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.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Jim Dettman (EE MVE)

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.
Karen Schaefer

ASKER
whats wrong wtiht this syntax

       (Reports![Report1]![txtEmpCt] " & intK.Visible) = True"
Karen Schaefer

ASKER
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
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Jim Dettman (EE MVE)

Report("txtEmpCt" & intK).Visible  = True

Jim.
Karen Schaefer

ASKER
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
Jim Dettman (EE MVE)

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.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Karen Schaefer

ASKER
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
sa
Jim Dettman (EE MVE)

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.
Jim Dettman (EE MVE)

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.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Karen Schaefer

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

Karen
Jim Dettman (EE MVE)

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

Jim.
OrgChartSample-new.zip
Karen Schaefer

ASKER
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
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Jim Dettman (EE MVE)

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.