using .addnew for a an entire table

icemonster

Registered User.
Local time
Today, 09:51
Joined
Jan 30, 2010
Messages
502
Code:
Set rs = CurrentDb.OpenRecordset("qry_employee")
    rs.AddNew
    rs.Fields("EMP_LASTNAME").Value = Me.txtLastName
    rs.Fields("EMP_FIRSTNAME").Value = Me.txtFirstName
    rs.Update
    rs.Bookmark = rs.LastModified
    lngPatientID1 = rs!ID_EMPLOYEE
    rs.Close
    Set rs = Nothing
    lngPatientID2 = lngPatientID1
Set rs = CurrentDb.OpenRecordset("

anyone know or could tell me how to convert this using an entire table instead? cause i need to query each primary key entered.
 
Use an update or append query to add the FirstName and LastName to the table - this will add all the names in one go and access will automatically add the value for the primary key - assuming you have an autonumber primary key.

Once you have the names in the table, you can use a query to look up the primary key for any name using DLookup. If you need all the primary key values, you can use a query based on the table and returning only one column - the primary key; or you can use a query returning 3 columns - primary key, first name and last name.

If you need help to build an append or update query, post back.
 

Users who are viewing this thread

Back
Top Bottom