Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access: Queries with junction tables

Status
Not open for further replies.

AnnIsabelle

Programmer
Apr 10, 2001
9
BE
Hi,
I have a problem with defining a query.
I have a database with a table Students and a table Courses. Between these two there is a junction table, cause students can choose multiple courses and courses can be chosen by multiple students.

Now I want to know from the group of students who have choosen course 10, which ones also choose course 5 or 6 of 7 ... I want to do the last step by using a parameter query.

I don't know how to do this in Access. Choosing "or" in the criteria of the query window gives me everyone who choose 10 or e.g. 5. And using "and" returns me 0 records, although there are students that fulfill the criteria.

Desperately in need of help,
AnnIsabelle
 
First, this should be posted in the Access Forms forum - you'll get more of a response.
You're query's tables should be :
tblStudents tblstudcour tblCourses

tblStudents connects through StudentID to StudentID of tblstudcour and tblCourses connects through CourseID to CourseID of tblstudcour.
tblstudcour has its own primary key, let's say studcourID.

You haven't made clear to what you want in your query. It seems like you want everyone with 10 OR (5 or 6 or 7). But you're asking for a parameter prompt. IT's quite confusing. Please restate it clearly.
 
Hi,
I know the structure of the database is correct, so that's not the problem.

My query has to resolve a problem with timetables of some courses. If course 10 ends at 10h00 and course 5 starts at 9h30 we have a problem. So in order to find out how many students are affected by this timetable, we want to use this query.

First I want the surname and firstname of all students who follow course 10. From that result I need to know who also follows course 5 (or any given course number, there's where the remark of the parameter query came from).

Greetz,
AnnIsabelle
 
So, set up a query with the three tables. In the grid, bring down firstname and lastname from the student table and course from the course table. On the criteria line under course, type in 10. This will give you all the students who take course 10. Now to extend it, on the row directly below 10, the OR row, type in a parameter prompt such as, [Enter another course number]. Now when it runs, it'll ask for a course number, eg. 5, and return all 10 and 5 students.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top