Count values from field in ADO Recordset 
Author Message
 Count values from field in ADO Recordset

Hello,

I have an ADO Recordset pointing to a database with time registration
information. I want to add a function where the user selects a project and
the application returns the total number of hours registered on that
project. Simplified example of my table:

Project
Hours
Minutes

First I set a filter like this: AdoDc1.Recordset.Filter = "Project ='" &
UserChoice & "'"

Now I want to count the values of the hours and minutes records to give the
user a total. I know I can loop through the recordset and add the values of
the bound textboxes, but I think this is not the most efficient way to go.

Any suggestions would be appreciated.

Thanks in advance,

Mark
(vb6sp5)



Wed, 14 Dec 2005 22:38:56 GMT  
 Count values from field in ADO Recordset
You can do it with a SQL query like this:

SELECT SUM(Hours) AS TotalHours,
       SUM(Minutes) AS TotalMinutes
FROM   table-name
WHERE  Project = project name/key

Don't forget to convert the TotalMinutes to hours/minutes and add the
right number of hours to TotalHours!

Quote:

> Hello,

> I have an ADO Recordset pointing to a database with time registration
> information. I want to add a function where the user selects a project and
> the application returns the total number of hours registered on that
> project. Simplified example of my table:

> Project
> Hours
> Minutes

> First I set a filter like this: AdoDc1.Recordset.Filter = "Project ='" &
> UserChoice & "'"

> Now I want to count the values of the hours and minutes records to give the
> user a total. I know I can loop through the recordset and add the values of
> the bound textboxes, but I think this is not the most efficient way to go.

> Any suggestions would be appreciated.

> Thanks in advance,

> Mark
> (vb6sp5)



Fri, 16 Dec 2005 21:39:41 GMT  
 Count values from field in ADO Recordset
That's exacly what I needed! Thanks David!

Mark


Quote:
> You can do it with a SQL query like this:

> SELECT SUM(Hours) AS TotalHours,
>        SUM(Minutes) AS TotalMinutes
> FROM   table-name
> WHERE  Project = project name/key

> Don't forget to convert the TotalMinutes to hours/minutes and add the
> right number of hours to TotalHours!




Quote:
> > Hello,

> > I have an ADO Recordset pointing to a database with time registration
> > information. I want to add a function where the user selects a project
and
> > the application returns the total number of hours registered on that
> > project. Simplified example of my table:

> > Project
> > Hours
> > Minutes

> > First I set a filter like this: AdoDc1.Recordset.Filter = "Project ='" &
> > UserChoice & "'"

> > Now I want to count the values of the hours and minutes records to give
the
> > user a total. I know I can loop through the recordset and add the values
of
> > the bound textboxes, but I think this is not the most efficient way to
go.

> > Any suggestions would be appreciated.

> > Thanks in advance,

> > Mark
> > (vb6sp5)



Mon, 19 Dec 2005 04:39:07 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. adodb connection to excel: recordset.fields(i).value=null for fields with numeric value

2. adodb connection to excel: recordset.fields(i).value=null for fields with numeric value

3. adodb connection to excel: recordset.fields(i).value=null for fields with numeric value

4. Editing a field value in a ADO Recordset

5. Assigning Null value to field of ADO Recordset

6. Count of records with field = <value>

7. Count table fields with specific value in SCR8.

8. Count field incorrect: not enough values for host variables

9. Recordset.Fields.Count problem

10. ADO Finding Highest Number in ADO Recordset field?

11. Record count for recordset created by executing an ADO command

12. need help on getting the auto-increment value of a field BEFORE updating recordset

 

 
Powered by phpBB® Forum Software