MySQL Forums
Forum List  »  Microsoft Access

Re: DAO/Access2k/MySQL5 rs.addnew #DELETED#
Posted by: Felix Bachmann
Date: August 30, 2005 07:36AM

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.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: DAO/Access2k/MySQL5 rs.addnew #DELETED#
2469
August 30, 2005 07:36AM


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.