Re: DAO/Access2k/MySQL5 rs.addnew #DELETED#
Just to wrap up this discussion. I had the same problem and thanks to Jake's comments I found a workable solution for me.
To look for the record where the primary key is NULL didn't work for me. The select statement did not return any record. The solution I found is probably exactly what the ODBC driver does to synchronize with a newly created record. I used a DATE field. Here is how it works:
Dim dateAdded As String
Set ntrst = CurrentDb.OpenRecordset("SomeTable")
dateAdded = Format(Now(), "mm/dd/yyyy hh:mm:ss")
ntrst.AddNew
... update some fields
ntrst![Date Entered] = dateAdded ' This is a date field
ntrst.Update
ntrst.Close
Set ntrst = Nothing
sql = "SELECT ID from [SomeTable] where [Date Entered]=#" & dateAdded & "#"
Set ntrst = CurrentDb.OpenRecordset(sql)
transid = ntrst!ID ' here I have the correct ID
This solution still has a little risk of getting the wrong record in a multi-user environment if two users add a record to the table at the same second, but in my envrionemnt, which does not have heavy concurrency, it works fine.
Subject
Views
Written By
Posted
5384
July 11, 2005 09:06PM
2559
July 12, 2005 06:42PM
2459
July 13, 2005 11:29AM
2385
July 13, 2005 12:28PM
2624
July 14, 2005 06:19PM
Re: DAO/Access2k/MySQL5 rs.addnew #DELETED#
2542
August 30, 2005 07:36AM
2787
September 12, 2005 05:55PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.