K
Kevin199
I have a table 'tblData' with 3 fields ID, Animal, Rating:
ID Animal Rating
1 Dog 16
1 Cat 19
1 Horse 20
2 Rabbit 15
2 Lion 19
2 Dog 20
2 Zebra 26
2 Mouse 19
3 Cow 20
4 Cat 23
4 Lion 17
4 Dog 15
4 Rabbit 12
I would like to make another table 'tblSummary' that summarizes my original
table in three fields ID, Animals, AvgRate:
ID Animals Avg Rate
1 Dog, Cat, Horse 18.3333
2 Rabbit, Lion, Dog, Zebra, Mouse 19.8
3 Cow 20
4 Cat, Lion, Dog, Rabbit 16.75
I have tried converting tblData into a recordset then looping through each
record using nested loops and using an INSERT INTO statement to put it into
tblSummary. My problem is that tblData is over 243,000 records and my code
takes a long time to run, like half an hour. Also, on long runs I sometimes
get the message: "Cannot open database 'mydb'. It may not be a Database that
your application recognizes, or the file may be corrupt." After repairing
and compressing, my application runs again slowly and sometimes crashing as
just described. Is there a more efficient way to accomplish my task?
ID Animal Rating
1 Dog 16
1 Cat 19
1 Horse 20
2 Rabbit 15
2 Lion 19
2 Dog 20
2 Zebra 26
2 Mouse 19
3 Cow 20
4 Cat 23
4 Lion 17
4 Dog 15
4 Rabbit 12
I would like to make another table 'tblSummary' that summarizes my original
table in three fields ID, Animals, AvgRate:
ID Animals Avg Rate
1 Dog, Cat, Horse 18.3333
2 Rabbit, Lion, Dog, Zebra, Mouse 19.8
3 Cow 20
4 Cat, Lion, Dog, Rabbit 16.75
I have tried converting tblData into a recordset then looping through each
record using nested loops and using an INSERT INTO statement to put it into
tblSummary. My problem is that tblData is over 243,000 records and my code
takes a long time to run, like half an hour. Also, on long runs I sometimes
get the message: "Cannot open database 'mydb'. It may not be a Database that
your application recognizes, or the file may be corrupt." After repairing
and compressing, my application runs again slowly and sometimes crashing as
just described. Is there a more efficient way to accomplish my task?