Append only the last row

Elmobram22

Registered User.
Local time
Today, 21:57
Joined
Jul 12, 2013
Messages
165
Hi,

Newby here to here and access really! I have an append query and want only the last row (Unique ID) to be added rather than the whole table. Is it do-able? Here is the SQL...

INSERT INTO TblCoursesRebooked ( StaffCourseID, Course, [Date], Staff, [Renewal Date] )
SELECT TblStaffCourse.StaffCourseID, TblStaffCourse.Course, TblStaffCourse.Date, TblStaffCourse.Staff, IIf(IsNull([Renewal in Years]),Null,DateAdd("yyyy",[Renewal in Years],[Date])) AS [Renewal Date]
FROM TblStaffCourse INNER JOIN (QryCourses INNER JOIN TblCourse ON QryCourses.CourseID = TblCourse.CourseID) ON TblStaffCourse.Course = QryCourses.[Course & Level]
GROUP BY TblStaffCourse.StaffCourseID, TblStaffCourse.Course, TblStaffCourse.Date, TblStaffCourse.Staff, IIf(IsNull([Renewal in Years]),Null,DateAdd("yyyy",[Renewal in Years],[Date]))
ORDER BY TblStaffCourse.StaffCourseID DESC;

Thanks in advance.

Paul:)
 
In the query property sheet set Top Values to 1 (one).
You must have a sort order that put that "last" record as the first record in your query.
 
In the query property sheet set Top Values to 1 (one).
You must have a sort order that put that "last" record as the first record in your query.

My lord I am in love with you!. Thanks so much. I've tried to sort that out for hours!!:D:D:D
 
Ok is there a way to append only new last row.

ie. unique numbers and not two of the same.

I have the query running on a button and if the button is pressed without data inputted it will add the last row again.

Not a major problem but trying to find a way of not letting the end user mess it up.
 
My English is not enough to understand if you are serious or not in post #3. :)
Well, transform that query into Append Query.
 

Users who are viewing this thread

Back
Top Bottom