Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

How do I use bookmark.lastmodified?

Avatar of Megin
Megin asked on
Microsoft Access
24 Comments1 Solution909 ViewsLast Modified:
I have a nice piece of code that I have gotten straightened out by people here, but now I need to mess it up some.
I have to take the primary key from the record that the code just added to a table and then add that to another table with information from a third field in the form.

I believe that I need to use "Bookmark.LastModified" but I am not sure how it works.

Currently the code looks like this:

Private Sub btn_AddtoTeam_Click()

 Dim rst As DAO.Recordset
 Dim strsql As String
 Dim TNAME As String

 TNAME = Forms!frm_Staff.Form!FName & " " & Forms!frm_Staff.Form!Lname
 strsql = "Select Top 1 * from Team"

    Set rst = CurrentDb.OpenRecordset(strsql)
    With rst
        ![TeamName] = TNAME
     End With  'rst

 Set rst = Nothing

 End Sub

I need to take the ID number (TeamID) created by this code and add it to a second table (TeamStaff) with the staff ID on the form (StaffID).

I know that I want to bookmark the last record that was created and then pull that ID number into the next table, but I don't know how to work that into the code.

Thank you for this and for all of the help preceding this!
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)Flag of United States of America imageDatabase Architect / Application Developer
This problem has been solved!
Unlock 1 Answer and 24 Comments.
See Answers