More AutoNumber Troubles

Results 1 to 2 of 2

Thread: More AutoNumber Troubles

  1. #1
    Dan C Guest

    Default More AutoNumber Troubles

    I&#039ve seen several responses to the problem of pulling the autonumber field from the row you just inserted. I&#039ve tried their code and it doesn&#039t seem to work for me. I&#039m using Access, and here is my code:<BR><BR>set oConn = CreateObject("ADODB.Connection")<BR>oConn.Open SecurityDSN<BR> set InsertUser = CreateObject("ADODB.Recordset")<BR> set InsertUser.ActiveConnection = oConn<BR> InsertUser.LockType = 3<BR> InsertUser.Source = "User" &#039 This is the Table Name<BR> InsertUser.CursorType = adOpenKeyset<BR> InsertUser.Open<BR> InsertUser.Addnew<BR> InsertUser("username") = Request("username")<BR> InsertUser.Update<BR> Id = InsertUser("UserID") <BR> Name = InsertUser("Username")<BR> InsertUser.Close<BR><BR> Response.Write("Did we get it?" & Id & "XX or the name?" & Name & "XX")<BR><BR>Each time Id is Null, but Name has the correct value. What am I doing wrong? Please Help!<BR><BR>Dan

  2. #2
    Rosco Guest

    Default RE: More AutoNumber Troubles

    Um, try reopening the recordset and then getting the new ID. It&#039s not very elegant but it&#039ll tell you if the autonumber field is written at UPDATE or at CLOSE.<BR><BR>Rosco

Posting Permissions

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