|
-
December 30th, 2005, 08:32 AM
#1
Searching a recordset and returning TOTALS
I have a database populated from users. I have another administrative app that we use to view what information the users have offered. I am now working on making a Totals report window, where it will show the "Totals" of certain things.
Take for example one of the user fields is level and it is basically a rating from 1 to 10. In my report I have a list labeled 1,2,3...,10 and beside each number, a total of how many people selected each such as:
10 7
9 0
8 3
7 2
etc, etc
Code:
Private Sub muViewAll_Click()
'first set my var to 0
level1 = 0
level2 = 0
level3 = 0
...
level10 =0
'next make sure that the recordset is on the first record
rs.movefirst
'I'm having a problem here, because if the user has been browsing
'through the records and absoluteposition <> 1 then the form is all
'jacked, but i think i can fix that one easily.
'ok start checking and collecting
do while not rs.EOF
if rs.Fields("level") = "1" then
level1 = level1 + 1
end if
if rs.fields("level") = "2" then
level2 = level2 + 1
end if
...
if rs.fields("level") = "10" then
level10 = level10 + 1
end if
'tried with
rs.movenext
'if i rem that line out, i get an overflow error
loop
frmReportAll.show
End Sub
now all of that works, but if you close out the report, and try to browse through the records using the first form, depending on what the absoluteposition was when you clicked on muViewAll, things go crazy. Is there a way to say
Code:
'before the loop see where absolutepostion is
strAP = rs.AbsolutePostion
'and when you come back from your report go back to the record you were at. because the loop throws off your actual position in the recordset.
Also.. is there an easier way to search and collect mass info from the recordset. I somewhat know how to use SQL statements, but I don't really know limitations or what not. It doesn't seem like you could use a SQL statement to check every record at once, and if true do something.
Alright well, any help is greatly appreciated. This is a very important project.
Thanks in Advance,
Buddy
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|