I have some code that creates a recordset from some tempory tables and then creates a new record in the live tables accordingly.
The next bit i need is to grab the primary key code as it is the foreign key in the next table i want to update against that product.
I dont seem to be able to grab the primary key, it returns a number but not the correct one.
here is what I have:
Dim RstCourseBk As DAO.Recordset
Set RstCourseBk = db.OpenRecordset("CourseBk")
While RstStudentDataToLive.EOF <> True
With RstStudentDataToLive
'get course detail from subform
'now add course data to live
With RstCourseBk
.AddNew
.Fields("STUDENT-DSN") = StudentID 'add student id
.Fields("COURSE-DSName") = RstStudentDataToLive.Fields(1).Value ' add product code
.Fields("Date") = Format(Now(), "dd/mm/yyyy")
.Fields("From") = RstStudentDataToLive.Fields(2).Value
.Fields("To") = RstStudentDataToLive.Fields(3).Value
.Fields("Description") = RstStudentDataToLive.Fields(4).Value
.Fields("PricePK") = RstStudentDataToLive.Fields(5).Value
.Update
End With 'rstcoursebk
'now we need the courseid of the record i just created
'lets delete that last record now its been added to the live system.
*********************************************
I NEED SOMETHING HERE TO GRAB THE PK OF THE LAST RECORD I JUST ADDED.
.FIELDS("pkFIELDNAME").VALUE DOESNT WORK
.Delete
.MoveNext
End With
Wend
regards
Peter
The next bit i need is to grab the primary key code as it is the foreign key in the next table i want to update against that product.
I dont seem to be able to grab the primary key, it returns a number but not the correct one.
here is what I have:
Dim RstCourseBk As DAO.Recordset
Set RstCourseBk = db.OpenRecordset("CourseBk")
While RstStudentDataToLive.EOF <> True
With RstStudentDataToLive
'get course detail from subform
'now add course data to live
With RstCourseBk
.AddNew
.Fields("STUDENT-DSN") = StudentID 'add student id
.Fields("COURSE-DSName") = RstStudentDataToLive.Fields(1).Value ' add product code
.Fields("Date") = Format(Now(), "dd/mm/yyyy")
.Fields("From") = RstStudentDataToLive.Fields(2).Value
.Fields("To") = RstStudentDataToLive.Fields(3).Value
.Fields("Description") = RstStudentDataToLive.Fields(4).Value
.Fields("PricePK") = RstStudentDataToLive.Fields(5).Value
.Update
End With 'rstcoursebk
'now we need the courseid of the record i just created
'lets delete that last record now its been added to the live system.
*********************************************
I NEED SOMETHING HERE TO GRAB THE PK OF THE LAST RECORD I JUST ADDED.
.FIELDS("pkFIELDNAME").VALUE DOESNT WORK
.Delete
.MoveNext
End With
Wend
regards
Peter