Possibly what is needed here is to add a new record and give it a student id number that is the next number.
An autonumber field does just that. It automatically assigns the next number, you need not do anything, in fact you cannot add or update that value.
The way that works at the nuts-and-bolts level of SQL would be like this-
Code:
INSERT STUDENT ( STUDENT.FORENAME, STUDENT.SURNAME, STUDENT.DOB, STUDENT.NCY )
VALUES ( "Bob", "Katt", "15/09/2004", 6)
Note that we are not supplying the STUDENT.ID. Autonumber will fillin that for a new row. In fact if we try to supply a value for that column we will get an error.
Are you building an application using Access Forms?
Or, maybe you want to look at the last student added. This would be
Code:
SELECT
STUDENT.FORENAME, STUDENT.SURNAME, to_char (STUDENT.DOB, 'DD/MM/YYYY'), STUDENT.ID, STUDENT.NCY
FROM
STUDENT
WHERE
STUDENT.NCY = 6
STUDENT.STUD_ID = ( SELECT MAX(STUD_ID) FROM STUDENT )
It may be that Access cannot handle this type of query. In that case you can define and save a query that provides nothing more than the last student id.
Code:
SELECT MAX(STUD_ID) AS "HiStudentID" FROM STUDENT
Save this and give it the name StudentLastID. When you display this guery it will have one row with the column name "HiStudentID".
Then define this query
Code:
SELECT *
FROM STUDENT
JOIN StudentLastID ON
StudentLastID.HiStudentID = STUDENT.ID
This will have one row which is the last row added. Actually the highest student id, which might be the last one added if student id is an autonumber column.
It may be that the DMax(expr, domain, criteria) function could be used in place of the StudentLastID query, but I have never figured out how to use it.