Record just added

Malcy

Registered User.
Local time
Today, 22:00
Joined
Mar 25, 2003
Messages
584
I have created a table tblMeetings where records of contact with clients are logged. The form is pre-populated with the client's name and then takes type of contact (e.g. email, face to face etc), the person dealing with it, the date, duration and any notes. Once the user clicks OK it appends a new record to tblMeetings.
I want to be able to track the ID of the record just added for audit purposes. There will always be a client, a type of contact, a person, a date and a duration. There may or may not be a note or comment.
But there could be several phone calls logged between the member of staff and the client on that day.
So how can I uniquely reference that record just added?
The app will be multi user so using DMax of the autonumber field will not always be right. If I use a general date to give date/time then how accurately does Access need that record to be - in other words if the recordset update line of code is followed by closing the recordset and then using a DLookup with something like timeadded = now() will the time still be the same or will the milliseconds lapsed throw it out?
I cannot believe my situation is unique and wondered how others deal with this.
Thanks for any pointers
Best wishes
 
If you're appending thru VBA and not by an append query, you might use the Bookmark method, like this:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblMeetings", dbOpenDynaset)
rs.Addnew
rs!ClientName = Me.txtClientName
rs!Date = Me.txtDate
... 'and so on for every field u want to append
rs.Update
rs.Bookmark = rs.LastModified
Me.txtLastAdded = rs!MeetingID
rs.Close

txtLastAdded will now be holding the ID of the last record added

HTH
Regards,
Premy
 
Thanks Premy
Worked a treat and since it is the line immediately after the recordset update I think it should be pretty bombproof.
Best wishes
 

Users who are viewing this thread

Back
Top Bottom