I am using VB6.0 for an assignment, it was so long that I used this. I'm trying to get the last inserted Id. My query is giving me the first row ID
I am using OLEDB. I have used some code but it is returning the first-row id.
Network
    rec.Open "staff_profile", con, adOpenDynamic, adLockOptimistic
    With rec
    .AddNew
      ![fields] = values
    .Save
      'rec.Update
  lastID = rec("ID")
  FileCopy frmRegister.cdl.FileName, fname & transcode & ".jpg"
    'return ID
    MsgBox "Record Saved Successfully " & lastID, vbInformation, "Trillium"
I want the result to give me the last inserted id
 
     
    