Get the id of a new record

Results 1 to 2 of 2

Thread: Get the id of a new record

  1. #1
    Join Date
    Dec 1969

    Default Get the id of a new record

    Hi,<BR><BR>I have an application that inserts data into a access 2k table then goes to a new form that submits to another table and so on. The first table has a field that is called case_id that is the autonumber. I need that number to insert into the second table where its not a autonumber. I&#039;m having trouble pulling that value to the second table, I saw some articles and have attempted to duplicate but I keep getting the same error, Item cannot be found in the collection corresponding to the requested name or ordinal line 79. Can any body shed some light.<BR><BR>SQL2="INSERT INTO individual_involved(name_of_individual_involved, name_of_agency_involved, employee_number) Values ("<BR><BR>SQL2 = SQL2 & "&#039;" & replace(session("name_of_individual_involved"),"&# 039;","&#039;&#039;") & "&#039;, "<BR>SQL2 = SQL2 & "&#039;" & session("name_of_agency_involved") & "&#039;, "<BR>SQL2 = SQL2 & "&#039;" & session("employee_number") & "&#039;); "<BR><BR>Set DbConn = Server.CreateObject("ADODB.Connection")<BR>x = Server.MapPath("security_incident2.mdb")<BR> DbConn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & x<BR><BR>DbConn.execute(SQL2) <BR><BR>&#039;response.write SQL2<BR>&#039;response.end<BR>DbConn.Close<BR>Set DbConn = Nothing<BR><BR>SQL = "Select @@IDENTITY"<BR><BR>Set DbConn = Server.CreateObject("ADODB.Connection")<BR>x = Server.MapPath("security_incident2.mdb")<BR>DbConn .Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & x<BR><BR>DbConn.execute(SQL)<BR>Set rs2 = Server.CreateObject("ADODB.Recordset")<BR> sql, DbConn<BR><BR>intCount = 1<BR><BR>Do Until rs2 Is Nothing<BR>If rs2.State = 1 Then<BR>Do Until rs2.EOF<BR>case_id = trim(rs2.fields("case_id")) THIS IS LINE 79<BR>rs2.MoveNext<BR>Loop<BR>End If<BR>Set rs2 = rs2.NextRecordset<BR>intCount = intCount + 1<BR>Loop<BR>DbConn.execute(SQL)<BR>DbConn.Close<B R>Set DbConn = Nothing<BR>

  2. #2
    Join Date
    Dec 1969
    Los Angeles, CA

    Default RTFFAQs <eop>


Posting Permissions

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