How to build a dynamic matrix type report

I just can't get my head around this and could use some help. I have a dynamic list of tech employees and will be maintained by an admin. The admins which check a Tech checkbox to make an employee show on the tech list.  We then have a list of clients, with one tech assigned to each client. The tech assignments will also be maintained by the admin to keep updated.

I need a report that will list the employees across the screen, list the Clients down the left column, with an X in the intersecting cell. At the bottom of the report, each employee will have a total number of client assignments.

Company   Employ1  Employ2  Employ3
----------- ----------- ----------- ----------
A               X
B                                              X
C                                 X
D               X
----------- ----------- ----------- ---------
Total         2                1            1

I can do this report if I hard code the employees and perform an Onformat event to see which column gets the X, and create variables to track how many X's are assigned to a given hard coded cell.  But I would like the columns to be dynamic as I know the list of techs will change down the road.

Any idea's how to approach this?
Thanks!
-Tom
LVL 4
ThirtAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nico5038Commented:
Making the columnheader and detaildata flexible is possible, but needs some VBA code in the OpenReport event.

To start, doing this you need to place the fields "coded" in the report.
The column headings should be called "lblCol1", "lblCol2", "lblCol3", etc.
The "detail" fields should be called "Col1", "Col2", "Col3", etc.

The report query has two rowheader columns and a Total column, therefor the first field is effectively column 4 (count starts at 0 so I used intI=3) but this could differ for you.

Make sure that the number of Columns is not bigger as the number placed. The programcode has no protection against that !

The OpenReport code:

Private Sub Report_Open(Cancel As Integer)
Dim intI As Integer

Dim rs As Recordset

Set rs = CurrentDb.OpenRecordset(Me.RecordSource)

'Place headers
For intI = 3 To rs.Fields.Count - 1
Me("lblCol" & intI - 1).Caption = rs.Fields(intI).Name
Next intI

'Place correct controlsource
For intI = 3 To rs.Fields.Count - 1
Me("Col" & intI - 1).ControlSource = rs.Fields(intI).Name
Next intI

'Place Total field
Me.ColTotal.ControlSource = "=SUM([" & rs.Fields(2).Name & "])"

End Sub

The report query has two rowheader columns and a Total column, therefor the first field is effectively column 4 (count starts at 0 so I used intI=3) but it could differ for you.

Clear ?

Nic;o)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ThirtAuthor Commented:
I think I follow that. I will need to follow up on this later, as I went ahead and completed the hard coded columns.

But a quick question, on the On-format event, I'm placing the X in the correct hard code column using a Case select. How do I keep a running total for the given columns when I place an X in it?

I was thinking of trying to following...
    Select Case fldemployeeindexno
        Case 378
            Me.coltj = "X"
            Me.colmb = ""
            Me.coltc = ""
            Me.coltb = ""
            Me.coljs = ""
            Me.colun = ""
            Me.txttj = 1
            Me.txtmb = 0
            Me.txttc = 0
            Me.txttb = 0
            Me.txtjs = 0
            Me.txtun = 0

But the control that performs sum([txttj]) doesn't find that control.

So how do I keep a running total for each column?
Thanks!!
nico5038Commented:
For a sum you can use:
=Sum(val([coltj))
this will ignore the "X".

Nic;o)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.