Query Confusion

aircuart

Registered User.
Local time
Today, 02:25
Joined
Sep 10, 2014
Messages
13
Hi,
I am using Acces 2003 and have created a Database for work. The main table has usual lastname, firstname etc and also courses (course1, course2 etc) which have a date carried out. Some of these records will be empty because the person has not done the course. I created Form(s) to input relavent data. No problems so far. I am now extracting the data via queries to output to reports. Some of these courses have a period of validity (3,4 or 5 years). I can do the Math in a query (or a calculated field on a report) with no problem. I then thought I would do a query with the following fields; lastname, firstname, course1, course2, course3. I then put is null in the OR bit of my query and ran it. I get the right data up (something like the below);
LName FName C1 C2 C3
Smith John 01/01/14 XXXX 01/01/14
Bloggs Jim 02/02/14 02/02/14 XXXX
Bland June XXXX 03/03/14 03/03/14

So it shows all the personnel with blanks (represented by xxxx). Fine so far, then I fall flat on my face. I would like to have a Query where I select the appropriate course from the my table and display it in a report (basically showing the people who need the course ie the blanks). This is probably remarkably easy but i think I have confused myself in trying to query queries. I imagined that I would open my report and a query would ask for course and that would pull the data from the query above. Apologies for wall of text and lack of uploaded examples but the work systems are limited. Also apologies for being a tad stupid and probably missing something very obvious! :confused:
 
Hi,

If I understand you right, you want something like this
Code:
SELECT LName, FName, IIf([Parameter:]="C1",[C1],IIf([Parameter:]="C2",[C2],[C3])) as Course FROM YourQuery;

This query will display always 3 columns, in the Course column's content will depend on the value you enter into the parameter.

Hope, I could help!

Regards,
VoiD
 
Thank You for the quick reply. Is this a new query to call on my original query, or have I misunderstood? I shall give it a try anyway tomorrow (when I am back in work) and hopefully have something positive to report!
 
Actually this query could be on top of your original query, but it could be on the table directly also. In this case, you should extend it with some conditions, as they are in your original query. The second case is better from point of view of performance.
 

Users who are viewing this thread

Back
Top Bottom