Complicated Problem.
My database is a student records database. I need to create a report that shows the total number of students applying for a particular course in a particular year categorised by their age. The age categories are Under 21, Between 21 and 25, Between 25 and 30 and Over 30. I've worked that out in as an expression in a query, which is fine. I've tried to base my report on a crosstab query which has the headings Year, Subject and then the above age cats going across the page with the total number of students in each cat shown. However, Access doesn't seem to like basing a report on a crosstab query that uses an expression (agecat) as a column because it is not a real field. So I've now got a form that asks for the criteria Year and Subject - once that's entered you press a button which runs a make table query and puts the correct data into the new table. This all works. Then on the criteria form the user presses another button to run the report. The report runs from a crosstab query which takes its data from the newly made table. This is also fine, except if there are 2 students - 1 under 21 and 1 over 30, the field names on the design of the report only show these 2 groups which you can then drag down onto the report. However, if you add another student aged between 21 and 25 for example, everything works except when you run the report only the previous categories ie under 21 and over 30 are shown as fields on the report because when you previously ran the report those were the only 2 fields coming from the newly made table. Alternatively, if you previously had 3 students - 1 in cat Under 21, 1 in cat Over 30 and 1 in cat Between 21 and 25 which fields you dragged into the design of the report, if you then take away the student say in the Over 30 range and then run the report again, it says that is doesn't recognise the Over 30 field name! So what I want is for the report to somehow incorporate all 4 age cats on it and if there are no ages in those cats, for it to just say 0. Please help if you can as I have spent hours and hours on this problem.
My database is a student records database. I need to create a report that shows the total number of students applying for a particular course in a particular year categorised by their age. The age categories are Under 21, Between 21 and 25, Between 25 and 30 and Over 30. I've worked that out in as an expression in a query, which is fine. I've tried to base my report on a crosstab query which has the headings Year, Subject and then the above age cats going across the page with the total number of students in each cat shown. However, Access doesn't seem to like basing a report on a crosstab query that uses an expression (agecat) as a column because it is not a real field. So I've now got a form that asks for the criteria Year and Subject - once that's entered you press a button which runs a make table query and puts the correct data into the new table. This all works. Then on the criteria form the user presses another button to run the report. The report runs from a crosstab query which takes its data from the newly made table. This is also fine, except if there are 2 students - 1 under 21 and 1 over 30, the field names on the design of the report only show these 2 groups which you can then drag down onto the report. However, if you add another student aged between 21 and 25 for example, everything works except when you run the report only the previous categories ie under 21 and over 30 are shown as fields on the report because when you previously ran the report those were the only 2 fields coming from the newly made table. Alternatively, if you previously had 3 students - 1 in cat Under 21, 1 in cat Over 30 and 1 in cat Between 21 and 25 which fields you dragged into the design of the report, if you then take away the student say in the Over 30 range and then run the report again, it says that is doesn't recognise the Over 30 field name! So what I want is for the report to somehow incorporate all 4 age cats on it and if there are no ages in those cats, for it to just say 0. Please help if you can as I have spent hours and hours on this problem.