473,605 Members | 2,590 Online
Bytes | Software Development & Data Engineering Community
+ 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

*tblGradingDate s*
DateID (PK)
GradeDate

*tblGrades*
GradeID (PK)
Grade
Requirements

*tblGradingDeta ils*
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 tblGradingDetai ls
ON tblGrades.Grade ID = tblGradingDetai ls.GradeID
WHERE (((tblGradingDe tails.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 2851
If you have the student's current grade, you could get the next grade like
this:
DMin("GradeID", "tblGrades","Gr adeID>" & 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,Require ments from tblGrades WHERE GradeID>" &
CurrentGrade & " ORDER BY GradeID"

HTH
- Turtle
"Stewart Allen" <sa****@ThisPar tNotVailid.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

*tblGradingDate s*
DateID (PK)
GradeDate

*tblGrades*
GradeID (PK)
Grade
Requirements

*tblGradingDeta ils*
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 tblGradingDetai ls
ON tblGrades.Grade ID = tblGradingDetai ls.GradeID
WHERE (((tblGradingDe tails.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.Grade ID = tblGradingDetai ls.GradeID + 1

AND never allow a person to get more then the max acceptable grade......
"Stewart Allen" <sa****@ThisPar tNotVailid.wave .co.nz> wrote in message news:<bp******* ***@news.wave.c o.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

*tblGradingDate s*
DateID (PK)
GradeDate

*tblGrades*
GradeID (PK)
Grade
Requirements

*tblGradingDeta ils*
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 tblGradingDetai ls
ON tblGrades.Grade ID = tblGradingDetai ls.GradeID
WHERE (((tblGradingDe tails.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********@nos pam.com> wrote in message
news:lq******** **********@news read2.news.atl. earthlink.net.. .
If you have the student's current grade, you could get the next grade like
this:
DMin("GradeID", "tblGrades","Gr adeID>" & 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,Require ments 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
1761
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 method of dataset). When doing the restore i have to overwrite the data from xml back to database. these are the steps that i follow. 1. get the data from database.
2
10045
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 form on which I am trying to do this. I wish to act on the presence (or absence) of this value. What I am doing is trying to have a generic password form such that when you click a button to open the next form, the code checks if there is a letter...
3
5211
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 memo will look something like this: Order: J123451 Placed By: Joe.systems,daily Order: J123452
2
2841
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. The SELECT query is built as follows: $itemtype = stripslashes(trim($_POST));
0
7934
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8425
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8418
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6743
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5886
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3912
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3958
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2438
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1541
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.