Transform Pivot query know fields

petebob796

Registered User.
Local time
Today, 03:24
Joined
Jul 31, 2007
Messages
27
I am working on a student register system, I am trying to modify someone else's existing access application and came across this:

TRANSFORM First(absence_code) AS FirstOfabsence_code
SELECT acad_period, student_id, register_id, register_group, First(absence_code) AS [Total Of absence_code]
FROM sttdstud, [Week No]
WHERE (((acad_period)>"03-04") AND ((week_no) Between 1 And [Week No]![WeekNo]))
GROUP BY acad_period, student_id, register_id, register_group
PIVOT week_no;


This generates records with a student_id, register_id register_group along with 53 fields numbered 1 to 53 (one for each week of the year plus overlap). Unfortunately if a register hasn't been marked for a week the field may never be generated and I want to concatenate all of these fields to make it easier to find students not attending (for instance not attended the last three times). If I try to concatenate the fields I will get an error if a field doesn't exist.

So is it possible to detect if a field exists before concatenating it (vba or sql but ideally sql) or alternatively force the pivot to create all the 1 to 53 fields.
 

Users who are viewing this thread

Back
Top Bottom