I have a timesheet form where the user is entering time in and time out and posting time to their time sheet. Those fields (time in, time out, hours worked) are static for each day of the week and easy to work with, so I'm automatically calculating the total hours worked for the week as they change the values. That's the easy part.
Now for the hard part. I have an "Add Leave" button which adds a row into the table (and onto the page) allowing the user to choose the type of leave (personal, sick, vacation). And across the Mon-Fri fields I need to subtotal the leave time (to the right of the row) as well as add it to a leave time subtotal and to the grand total at the bottom of the page.
It wouldn't be such an issue if there wasn't so many different leave types and the ability to add many different leaves each week for the timesheet. For example, the user may have 2 hours vacation time, 2 hours personal time and four hours Leave without pay for one particular day. In this case, the user will continue to add new rows, select the leave type and fill in the hours across the week.
I'm thinking that I need to name the fields in a unique way so that when I'm adding them up, I'll know it's leave time. For example LV_201_Mon, LV_201_Tue, LV_201_Wed, etc. In this case, the id of 201 tells me which leave that they are reporting. How the heck to I add up all these different rows when I have no clue what they're going to be called. Is there a way to loop through a "collection" of fields on a form, and then if it starts with LV, I could just add it to the leave subtotal? I'm stumped.
Thanks in advance for any help you can provide. Sorry about the lengthy message.
Is there a location where we can see your time sheet?
There are plenty of ways to do this and it is possible to loop through collections. Most collections have a COUNT property that can be used to learn how many items are in the collection and for/next through it.
I might create a table within the sheet to hold just the Leave Items. Then one could process that table's items without having to filter out regular time.