473,490 Members | 2,487 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Finding next value in table

I'm trying to find the next value in a table that a student needs to achieve
once he has already passed one grade.

*tblStudents*
StudentID (PK)
FirstName

*tblGradingDates*
DateID (PK)
GradeDate

*tblGrades*
GradeID (PK)
Grade
Requirements

*tblGradingDetails*
DateID (FK) M -1 tblGradingDates
StudentID (FK) M -1 tblStudents
GradeID (FK) M -1 tblGrades
Cost

One student can go for many grades but only one grade at a time. One grading
can have many students going for a grade. What I'm after is to find what the
next Grade(ID) and requirements are for a student. The requirements are what
the student has to do before he can go for that grade.

I can find a student's current grade (StudentID =1) by using:
SELECT Last(tblGrades.Grade) AS LastGrade
FROM tblGrade INNER JOIN tblGradingDetails
ON tblGrades.GradeID = tblGradingDetails.GradeID
WHERE (((tblGradingDetails.StudentID)=1));

Is there any SQL statement that I can use that will find from tblGrades what
the next grade and requirements for that grade are for a student? Looping
through a recordset using DAO is something I'd do as the last resort. The
GradeID's are in numeric order.

TIA
Stewart

Nov 12 '05 #1
3 2841
If you have the student's current grade, you could get the next grade like
this:
DMin("GradeID","tblGrades","GradeID>" & CurrentGrade)
You could then use DLookup to get the requirements.

You can use the same logic in a query, too.
Or you could use something like this:
"SELECT TOP 1 GradeID,Requirements from tblGrades WHERE GradeID>" &
CurrentGrade & " ORDER BY GradeID"

HTH
- Turtle
"Stewart Allen" <sa****@ThisPartNotVailid.wave.co.nz> wrote in message
news:bp**********@news.wave.co.nz...
I'm trying to find the next value in a table that a student needs to achieve once he has already passed one grade.

*tblStudents*
StudentID (PK)
FirstName

*tblGradingDates*
DateID (PK)
GradeDate

*tblGrades*
GradeID (PK)
Grade
Requirements

*tblGradingDetails*
DateID (FK) M -1 tblGradingDates
StudentID (FK) M -1 tblStudents
GradeID (FK) M -1 tblGrades
Cost

One student can go for many grades but only one grade at a time. One grading can have many students going for a grade. What I'm after is to find what the next Grade(ID) and requirements are for a student. The requirements are what the student has to do before he can go for that grade.

I can find a student's current grade (StudentID =1) by using:
SELECT Last(tblGrades.Grade) AS LastGrade
FROM tblGrade INNER JOIN tblGradingDetails
ON tblGrades.GradeID = tblGradingDetails.GradeID
WHERE (((tblGradingDetails.StudentID)=1));

Is there any SQL statement that I can use that will find from tblGrades what the next grade and requirements for that grade are for a student? Looping
through a recordset using DAO is something I'd do as the last resort. The
GradeID's are in numeric order.

TIA
Stewart

Nov 12 '05 #2
I would add one additional record to Grades (one more then the max grade that
can be acheived - something like - you're at the max type of grade)

In the select just add one to GradeID (since you state they're in numeric order)
ON tblGrades.GradeID = tblGradingDetails.GradeID + 1

AND never allow a person to get more then the max acceptable grade......
"Stewart Allen" <sa****@ThisPartNotVailid.wave.co.nz> wrote in message news:<bp**********@news.wave.co.nz>...
I'm trying to find the next value in a table that a student needs to achieve
once he has already passed one grade.

*tblStudents*
StudentID (PK)
FirstName

*tblGradingDates*
DateID (PK)
GradeDate

*tblGrades*
GradeID (PK)
Grade
Requirements

*tblGradingDetails*
DateID (FK) M -1 tblGradingDates
StudentID (FK) M -1 tblStudents
GradeID (FK) M -1 tblGrades
Cost

One student can go for many grades but only one grade at a time. One grading
can have many students going for a grade. What I'm after is to find what the
next Grade(ID) and requirements are for a student. The requirements are what
the student has to do before he can go for that grade.

I can find a student's current grade (StudentID =1) by using:
SELECT Last(tblGrades.Grade) AS LastGrade
FROM tblGrade INNER JOIN tblGradingDetails
ON tblGrades.GradeID = tblGradingDetails.GradeID
WHERE (((tblGradingDetails.StudentID)=1));

Is there any SQL statement that I can use that will find from tblGrades what
the next grade and requirements for that grade are for a student? Looping
through a recordset using DAO is something I'd do as the last resort. The
GradeID's are in numeric order.

TIA
Stewart

Nov 12 '05 #3
Thanks for that Turtle. Didn't think about using DMin and DLookup in that
way. I'll probably use your query solution to utilise Jet's engine.

Stewart
"MacDermott" <ma********@nospam.com> wrote in message
news:lq******************@newsread2.news.atl.earth link.net...
If you have the student's current grade, you could get the next grade like
this:
DMin("GradeID","tblGrades","GradeID>" & CurrentGrade)
You could then use DLookup to get the requirements.

You can use the same logic in a query, too.
Or you could use something like this:
"SELECT TOP 1 GradeID,Requirements from tblGrades WHERE GradeID>" &
CurrentGrade & " ORDER BY GradeID"

HTH
- Turtle


Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1751
by: Devesh Aggarwal | last post by:
Hi, I have a backup and restore module in my project. The backup uses a typed dataset object (XSD) to get the data from database and creates a xml file as the backup file (using the WriteXml...
2
10027
by: dixie | last post by:
I am trying to write some VBA that can check if a certain value exists in a field in a table. The field is a text field. The table is not a part of the query that forms the recordsource of the...
3
5203
by: Helgardh | last post by:
I have a linked table (Access 2003) to an Outlook inbox. The body of the e-mail messages are in a memo field. My problem is that I need to "read" the memo and find data on certain lines. The...
2
2835
by: ElkGroveR | last post by:
Hi there! I'm using PHP to create a simple, dynamic MySQL SELECT query. The user chooses a selection from a HTML Form SELECT element's many options and submits the form via a POST action. ...
0
7112
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6974
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7146
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6852
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4878
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4573
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3074
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
628
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
277
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.