I am coding some new forms and i need some help i believe.
Here is what i want to do:
I have a table called tblComparison - this table has the following columns:
- fldDate
- fldAverage
- fldMorning8am
- fldMorning11am
- fldLunch2pm
- fldAfternoon6pm
- fldNight1159pm
The 5 last columns have numbers entered. The first column has a date entered in the form of DD/MM/YYYY.
(1) In the form i will have ListBox, the user will select a Month - basically lets say the user chooses December the choice will be 31/12/2011
(2) I will need to select from the database all of the rows that have fldDate set from 01/12/2011 to 31/12/2011.
(3) I will need to probably enter the values of the rows in a array or something.
(4) For each row the program needs to find the average so it needs to do fldMorning8am + fldMorning11am + fldLunch2pm + fldAfternoon6pm + fldNight1159pm and then divide the answer by 5 and it needs to insert the answer to the relative row in fldAverage Column
(5) For each of the columns (fldMorning8am, fldMorning11am, fldLunch2pm, fldAfternoon6pm, fldNight1159pm) i need to find the average of the rows in that column.
What i mean is that lets say there are 3 rows with the following details:
12122011 7 7 3 7 7 7
13122011 6 7 7 7 1 7
14122011 7 5 7 2 7 8
(the first column is fldDate, the second here is fldAverage and so on)
So fldMorning8am (third column) column has the following values: 7, 6, 7
I want to take those three values, plus them and then divide them by 3 (since in this case its 3 columns) to get an average, so 7+6+7 = 20 then 20/3 = 6.6666666667
Once the averages for each column are created it needs to save them to tblMonthlyComparison - again the column names in this table are the same so in the fldDate column the program needs to enter 31/12/2011. In fldAverage of this table what we do is take the average that we found above for each column then plus them together and divide them by 5.
I appreciate any assistance, as a note this coding will go in a open source program that i am working on.