and also, sum an unknown number of fields' data for each row
before anyone says that my database is not normalized and there's no way there should be all these rows, i'm just automating someone's report and it was easier for me to just keep sutomatically adding 4 fields every month than to normalize it and then write code to put it back together they way they need it to look
so i'm working with their look to begin with
here's the way it looks
week1 week2 week3 week4 week5 week6 grandtotal
maibox1 5 3 7 5 7 6
mailbox2 8 4 6 3 5 8
mailbox3 3 5 3 2 4 5
mailbox4 4 5 2 4 2 5
grand total
i need to calculate the totals for both the GRANDTOTALs on the right and on the bottom
right now there's about 70 columns and as i said, every month 4 more keep adding
i know i have to do a loop to loop through all the fields, but how do i write the loop so it knows to check that the fields exists (i have a function that does that, here it goes)
so wither with this function, or some other way, how can i do this?
thank you!!!
before anyone says that my database is not normalized and there's no way there should be all these rows, i'm just automating someone's report and it was easier for me to just keep sutomatically adding 4 fields every month than to normalize it and then write code to put it back together they way they need it to look
so i'm working with their look to begin with
here's the way it looks
week1 week2 week3 week4 week5 week6 grandtotal
maibox1 5 3 7 5 7 6
mailbox2 8 4 6 3 5 8
mailbox3 3 5 3 2 4 5
mailbox4 4 5 2 4 2 5
grand total
i need to calculate the totals for both the GRANDTOTALs on the right and on the bottom
right now there's about 70 columns and as i said, every month 4 more keep adding
i know i have to do a loop to loop through all the fields, but how do i write the loop so it knows to check that the fields exists (i have a function that does that, here it goes)
Code:
Function FieldExists(ByVal fieldName As String, ByVal tableName As String) As Boolean
Dim db As Database
Dim tbl As TableDef
Dim fld As Field
Dim strName As String
Set db = CurrentDb
Set tbl = db.TableDefs(tableName)
For Each fld In tbl.Fields
If fld.Name = fieldName Then
FieldExists = True
Exit For
End If
Next
End Function
so wither with this function, or some other way, how can i do this?
thank you!!!