I'm experimenting with a report where the Project Managers can play around with the hours of employees and see how it would impact their budgets. I've got a report that shows a project's employee list with budgeted hours/cost and actual hours/cost. I've removed the actual figures and am including a variance column to hold the number of hours the PM wants to change (-/+ #).
I'm using 2 parameters to allow the PM to enter their proposed changes: one is a drop-down list of employees on that specific project and the other is a text box where they can manually enter a number representing the hours they want added/deducted from the employee's budgeted hours.
I'm using global variables to hold the hours entered and the id of the employee chosen
In a column of the details part of my table I'm calling a function and passing the employee id of that row's data and the parameters selected
=Code.getAdjustedHours(Fields!WipEmp_ID.Value, Parameters!Hours.Value, Parameters!EmployeeID.Value)
My function tests to see if the current employee id matches the one selected from the drop-down and if so it assigns the hours entered to the hours variable
Dim public adjustHours as String
Dim public adjustingEmployee as String
Public Function getAdjustedHours(ByVal e as String, ByVal h as String, ByVal c as String)
Dim empID as String= e
adjustingEmployee = c
adjustHours = "0"
If (adjustingEmployee = empID) Then
adjustHours = h
This is working great in that I can change the employee and hours and the table updates appropriately as to who should get the added/subtracted hours. But it only works for the currently adjusted employee. If I select a new employee and enter a new hour amount then the previous entry is lost.
Note* I'm not sending this information to the database; it is intended for PM's to play around with the team's hours and see the changes it would cause to the budget given the varying pay rates
I'd like to change my function so that it uses a two-dimensional array using RowCount to set the size of the array and entering the employee id as the identifier and all 0's as the hours. Then as the hours are entered I'd use the employee id parameter to attach hours to that employee. Then under New Hours I'd take the currently recorded hours budgeted and add the hours of the array to the employee's hours to get the new hours. Then multiply that by their rate the new cost associated with those changes.
It's been a number of years since I programmed with VB so I'm at a bit of a loss at how to change the global hours variable to a global array and how to set the hours to 0 initially, then add the hours added. Any help is greatly appreciated!!!!