This topic is locked
[SOLVED]

 After Add Event - Last Record ID

7/5/2012 7:07:05 PM
ASPRunnerPro General questions
M
McGowan author

I have a page with an After Add event that adds records to two other tables. Each of these tables has its own ID field (autonumber). When I add a new record to Table_A, I need to first add a new record to Table_B with information from Table_A, then I need to add information to Table_C with the ID from Table_B and data from Table_A. Everything is working except the part that requires getting the "last record added ID" from Table_B.
What is the code for accomplishing this?

M
McGowan author 7/5/2012

I think I figured it out. Here is what I used that is working. If someone has a better or more efficient method, I'm open to suggestion.



str = "select max(RecordID) from Table_B"

Set rstmp = server.CreateObject("ADODB.Recordset")

rstmp.open str,dbConnection
dal.Table_C.OtherRecordID=rstmp(0)

dal.Table_C.Add()

rstmp.close

set rstmp=nothing


FYI - I'm using ASPRP 6.1 for this project. I have 7.0 but haven't been able to successfully convert it to the latest version.
I see that 7.1 can convert 6.2 and later projects..... just my luck I'm using 6.1. I wonder if I can go 6.1 to 6.2 to 7.1.??????