Mutiple quarry in a column..

musaad

New member
Local time
Today, 16:29
Joined
Apr 18, 2014
Messages
7
Hello Guru's of Access....

I need your help on quarries....
I have create few option buttons in a form and assigned values. when each option button selected it will store a value in tbl.attend.log

Exp - Opt 1 button = 1 = OnDuty
Opt 2 Button = 2 = DutyTravel
Opt 3 Button = 3 = SeekLeave

tbl.attend.log
ST_Name ST_Date ST_Attend
Tom 01/04/2014 1
Jim 01/04/2014 1
Harry 01/04/2014 1
Tom 02/04/2014 1
Jim 02/04/2014 2
Harry 02/04/2014 1
Tom 03/04/2014 3
Jim 03/04/2014 1
Harry 03/04/2014 2

i would like to display above data as below when i run a quarry Group By ST_Name , Between dates, Count ST_Attend

ST_Name OnDuty DutyTravel SeekLeave
Tom 2 0 1
Jim 2 1 0
Harry 2 1 0

I manage do a quarry as below

SELECT tbl_attend_log.ST_Name, Count(tbl_attend_log.ST_Attend) AS OnDuty,
FROM tbl_attend_log
WHERE (((tbl_attend_log.ST_Date) Between [Forms]![frm_StaffAttend_form]![Text19] And [Forms]![frm_StaffAttend_form]![Text20]) AND ((tbl_attend_log.ST_Attend) Like '1'))
GROUP BY tbl_attend_log.ST_Name;

Output was
ST_Name OnDuty
Tom 2
Jim 2
Harry 2

Can any one help me .............
 
I'm not clear on what the problem is?

I have a table named tbl_attend_log with the below data

ST_Name ST_Date ST_Attend
Tom 01/04/2014 1
Jim 01/04/2014 1
Harry 01/04/2014 1
Tom 02/04/2014 1
Jim 02/04/2014 2
Harry 02/04/2014 1
Tom 03/04/2014 3
Jim 03/04/2014 1
Harry 03/04/2014 2

ST_Attend column data values are from a Option button in form.

Opt button 1 = 1= OnDuty
Opt button 2 = 2= DutyTravel
Opt button 3 = 3 = SickLeave

I need a quarry when I enter two dates it should Count the ST_Attend column values as the criteria in the Option button and group by ST_Name
example output should look like below.

ST_Name OnDuty DutyTravel SickLeave
Tom 2 0 1 Jim 2 1 0
Harry 2 1 0

any idea how I can do it..........
 

Users who are viewing this thread

Back
Top Bottom