Last Record

Results 1 to 3 of 3

Thread: Last Record

  1. #1
    Join Date
    Dec 1969

    Default Last Record

    I&#039;m trying to display the ID of a record that&#039;s just been added to my database (I know, I&#039;ve seen articles describing it, but for some reason it doesn&#039;t work in my code). The error I&#039;m getting now is:<BR>Microsoft JET Database Engine error &#039;80040e24&#039; <BR><BR>Rowset does not support fetching backward. <BR><BR>/techtasks/submitnew.asp, line 66 <BR><BR>This is the code:<BR>conn.Execute "INSERT INTO t_Tech_Task_List (Appl_ID, Category_ID, Task, Owner, Status_ID, Notes, Date_Logged) values (&#039;" _<BR>& Appl_ID & "&#039;,&#039;" _<BR>& Category_ID & "&#039;,&#039;" _<BR>& Task & "&#039;,&#039;" _<BR>& Owner & "&#039;,&#039;" _<BR>& Status_ID & "&#039;,&#039;" _<BR>& Notes & "&#039;,&#039;" _<BR>& Date_Logged & "&#039;)", Recordsaffected<BR> set rs = Server.CreateObject("ADODB.Recordset")<BR> rs.Open "t_Tech_Task_List", conn<BR> rs.MoveLast<BR> NewID=rs("ID")<BR> Response.write("Task added with ID number" & NewID & "<BR>")<BR>If I leave out the rs.MoveLast, NewID returns some record in the middle of my database, not the one I just added.

  2. #2
    Lurker Guest

    Default RE: Last Record

    Well, you should go back and read the articles again.<BR><BR>The way you are trying to do it will get the last record added, NOT neccesarily the one YOU just added. Someone else may also be on the site, and have added one since I know it MAY sound unlikely, but trust me it will happen.<BR><BR>As for the error message, read up on cursor types.

  3. #3
    NPKumar Guest

    Default RE: Last Record

    select Max(ID) from tablename .<BR>I think it will solve your problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts