P
Phil Hellmuth
Using the AddNew Method, I'm adding a row into a table (linked via
SQLServer). I want to capture the ID of the row I just added, but I'm
actually getting the ID from the first row in the table. Here's a
simulation of what I'm doing:
set rs = db.OpenRecordset("Students", dbOpenDynaset, dbSeeChanges)
rs.AddNew
rs("StudentName") = "Joe Smith"
rs.Update
lngID = rs("StudentID")
rs.Close
lngID is the ID of the first row in the table, not the ID of the row I
just added.
I could have sworn I've done this successfully in the past. Is the
dbOpenDynaset option throwing me off? I added it because it seemed
dbSeeChanges required it, and the existence of an Identity column forced
me to use the dbSeeChanges option.
Thanks in advance.
SQLServer). I want to capture the ID of the row I just added, but I'm
actually getting the ID from the first row in the table. Here's a
simulation of what I'm doing:
set rs = db.OpenRecordset("Students", dbOpenDynaset, dbSeeChanges)
rs.AddNew
rs("StudentName") = "Joe Smith"
rs.Update
lngID = rs("StudentID")
rs.Close
lngID is the ID of the first row in the table, not the ID of the row I
just added.
I could have sworn I've done this successfully in the past. Is the
dbOpenDynaset option throwing me off? I added it because it seemed
dbSeeChanges required it, and the existence of an Identity column forced
me to use the dbSeeChanges option.
Thanks in advance.