I have code in the DAO that connects to a linked table in SQL Server 2008. I need to get the newly created auto number on .AddNew .
Set db = CurrentDb Set rs = db.OpenRecordset("AuditTrail") rs.AddNew rs("ActionID") = actionAdd rs("dtDateTime") = Now() rs("FormName") = frmName rs("TableName") = tblName rs("RecordID") = actionAdd rs("Comment") = Nz(comment, "") rs("UserID") = UserIDName rs("UsernamePC") = VBA.Environ("USERDOMAIN") rs("DomainPC") = VBA.Environ("USERDOMAIN") rs("ComputerNamePC") = VBA.Environ("COMPUTERNAME") rs.Update rs.Close
If I use rs("AuditTrailID") before rs.Close , it returns 1 (first record).
source share