Eiredrake
Nov 11th, 2000, 05:53 PM
I have a bit of a problem and I cant' seem to find away around it. Any help would be appreciated.
I am using an Access Database (currently using Access97, SR2), VB6 SPIII and have the following references in the project. I am using a Datagrid to display my data.
References:
Microsoft ActiveX Data Objects 2.0 Library
Microsoft Data Binding Collection
I have a table in the database which is linked to another table by a common ID. Each IDNumber represents 1 person who works a specified number of hours each day. What I'd like to do is to create a Total for each person of hours that they have worked during the week. Sounds Simple dont it!
Unfortunately it isnt. The table that holds the data for each rep has all of the data for all of the reps in it for every day. What I need to do is take only the Values for each rep for THIS week and Sum them. Then display them with Each person as 1 row in the Datagrid and only their Totals showing.
Below is an idealized example of the data in the two tables. There is actually a lot more data to it. There is also two fields in the RepTable which contain the names that belong to the ID numbers, which is what I want to display in the Datagrid instead of the ID number. (As if this wasn't complicated enough)
------
[WeekData]
IDNUM DATE Contr Uncon
111-11-1111 11/1/00 06:00 02:00
222-22-2222 11/1/00 06:00 02:00
333-33-3333 11/1/00 06:00 02:00
111-11-1111 11/2/00 06:00 02:00
222-22-2222 11/2/00 06:00 02:00
333-33-3333 11/2/00 06:00 02:00
111-11-1111 11/3/00 06:00 02:00
222-22-2222 11/3/00 06:00 02:00
333-33-3333 11/3/00 06:00 02:00
111-11-1111 11/4/00 06:00 02:00
222-22-2222 11/4/00 06:00 02:00
333-33-3333 11/4/00 06:00 02:00
111-11-1111 11/5/00 06:00 02:00
222-22-2222 11/5/00 06:00 02:00
333-33-3333 11/5/00 06:00 02:00
111-11-1111 11/6/00 06:00 02:00
222-22-2222 11/6/00 06:00 02:00
333-33-3333 11/6/00 06:00 02:00
[RepTable]
IDNUM FirstName LastName
111-11-1111 Bob Robertson
222-22-2222 Arnold Musclehugger
333-33-3333 Homie TheClown
--------
Now I know what you're thinking.... Use the SUM() SQL statement. Well I tried that, and it's giving me an error because I am not trying to sum the ID and Date fields.
What I need is basically this SQL statement:
"SELECT SUM(Contr),SUM(Uncon),Date,IDNUM FROM [WeekData], FirstName,Lastname FROM [RepTable] WHERE IDNUM=" xx " AND Date BETWEEN " MondaysDate " AND " SaturdaysDate
xx=A sum for each Rep
----
So That each row in the datagrid looks like this:
FirstName LastName Contr Uncon
Bob Robertson 30:00 10:00
Arnold Musclehugger 30:00 10:00
Homie TheClown 30:00 10:00
This is unfortunately a project I'm working on for my Internship through my college for my AAS degree. I'm close to completetion but I've only got 4 weeks left to finish this project! So any help would be appreciated, especially if it's FAST help.
Thanks,
Eiredrake
I am using an Access Database (currently using Access97, SR2), VB6 SPIII and have the following references in the project. I am using a Datagrid to display my data.
References:
Microsoft ActiveX Data Objects 2.0 Library
Microsoft Data Binding Collection
I have a table in the database which is linked to another table by a common ID. Each IDNumber represents 1 person who works a specified number of hours each day. What I'd like to do is to create a Total for each person of hours that they have worked during the week. Sounds Simple dont it!
Unfortunately it isnt. The table that holds the data for each rep has all of the data for all of the reps in it for every day. What I need to do is take only the Values for each rep for THIS week and Sum them. Then display them with Each person as 1 row in the Datagrid and only their Totals showing.
Below is an idealized example of the data in the two tables. There is actually a lot more data to it. There is also two fields in the RepTable which contain the names that belong to the ID numbers, which is what I want to display in the Datagrid instead of the ID number. (As if this wasn't complicated enough)
------
[WeekData]
IDNUM DATE Contr Uncon
111-11-1111 11/1/00 06:00 02:00
222-22-2222 11/1/00 06:00 02:00
333-33-3333 11/1/00 06:00 02:00
111-11-1111 11/2/00 06:00 02:00
222-22-2222 11/2/00 06:00 02:00
333-33-3333 11/2/00 06:00 02:00
111-11-1111 11/3/00 06:00 02:00
222-22-2222 11/3/00 06:00 02:00
333-33-3333 11/3/00 06:00 02:00
111-11-1111 11/4/00 06:00 02:00
222-22-2222 11/4/00 06:00 02:00
333-33-3333 11/4/00 06:00 02:00
111-11-1111 11/5/00 06:00 02:00
222-22-2222 11/5/00 06:00 02:00
333-33-3333 11/5/00 06:00 02:00
111-11-1111 11/6/00 06:00 02:00
222-22-2222 11/6/00 06:00 02:00
333-33-3333 11/6/00 06:00 02:00
[RepTable]
IDNUM FirstName LastName
111-11-1111 Bob Robertson
222-22-2222 Arnold Musclehugger
333-33-3333 Homie TheClown
--------
Now I know what you're thinking.... Use the SUM() SQL statement. Well I tried that, and it's giving me an error because I am not trying to sum the ID and Date fields.
What I need is basically this SQL statement:
"SELECT SUM(Contr),SUM(Uncon),Date,IDNUM FROM [WeekData], FirstName,Lastname FROM [RepTable] WHERE IDNUM=" xx " AND Date BETWEEN " MondaysDate " AND " SaturdaysDate
xx=A sum for each Rep
----
So That each row in the datagrid looks like this:
FirstName LastName Contr Uncon
Bob Robertson 30:00 10:00
Arnold Musclehugger 30:00 10:00
Homie TheClown 30:00 10:00
This is unfortunately a project I'm working on for my Internship through my college for my AAS degree. I'm close to completetion but I've only got 4 weeks left to finish this project! So any help would be appreciated, especially if it's FAST help.
Thanks,
Eiredrake