S
Syed Zeeshan Haider
Hello Everybody,
In Access 2003, I have two tables i.e. "Students" and "Marks".
"Students" is simply the list of students while "Marks" is the list of total
marks each student earned in a certain exam. "Marks" table uses the names
from the "Students" table. In "Marks", I have a field called "StudentID"
(with Number Data Type) which retrieves the names of the students from
"Students" table using their numerical primary key (I borrowed this
technique
from "Northwind.mdb" sample file).
I have written a VBA procedure which should pick top ten students based on
their marks from "Marks" table and put their names in another table called
"Archives". In my VBA code I have put following SQL code:
SELECT MIN(Topper) AS Second FROM (SELECT TOP 2 [Marks].StudentID AS Topper
FROM [Marks] ORDER BY [Marks].MarksCount DESC);
This SQL chunk should be run 10 times and the number in SELECT TOP 2 (here
it
is 2) should be different every time as 1 should return highest scorer
student, 2
should return second highest and so forth.
Anyways, above query is returning the ID (or primary key) from "Students"
table, instead of returning name of the student from "Marks" table?
Can someone figure out what am I missing here?
Thank you,
In Access 2003, I have two tables i.e. "Students" and "Marks".
"Students" is simply the list of students while "Marks" is the list of total
marks each student earned in a certain exam. "Marks" table uses the names
from the "Students" table. In "Marks", I have a field called "StudentID"
(with Number Data Type) which retrieves the names of the students from
"Students" table using their numerical primary key (I borrowed this
technique
from "Northwind.mdb" sample file).
I have written a VBA procedure which should pick top ten students based on
their marks from "Marks" table and put their names in another table called
"Archives". In my VBA code I have put following SQL code:
SELECT MIN(Topper) AS Second FROM (SELECT TOP 2 [Marks].StudentID AS Topper
FROM [Marks] ORDER BY [Marks].MarksCount DESC);
This SQL chunk should be run 10 times and the number in SELECT TOP 2 (here
it
is 2) should be different every time as 1 should return highest scorer
student, 2
should return second highest and so forth.
Anyways, above query is returning the ID (or primary key) from "Students"
table, instead of returning name of the student from "Marks" table?
Can someone figure out what am I missing here?
Thank you,