strSQL = "INSERT INTO tbl_school ( school_name, school_degree, school_major, school_startdate, school_enddate ) SELECT tmptbl_school.school_name, " _
& "tmptbl_school.school_degree, tmptbl_school.school_major, tmptbl_school.school_startdate, tmptbl_school.school_enddate FROM tmptbl_school "
.Execute strSQL, , adCmdText + adExecuteNoRecords
strSQL = "SELECT Last_Insert_ID();"
With .Execute(strSQL, , adCmdText)
If Not (.BOF And .EOF) Then
' Found the new ID - build the second Insert SQL string
lngLastSchoolID = .Fields(0)
Else
' Abort
End If
.Close
End With
strSQL = "INSERT INTO tbl_address ( address_street1, address_street2, address_city, address_state, address_zipcode, address_country ) SELECT temptbl_address.address_street1, " _
& "temptbl_address.address_street2, temptbl_address.address_city, temptbl_address.address_state, temptbl_address.address_zipcode, " _
& "temptbl_address.address_country FROM temptbl_address "
.Execute strSQL, , adCmdText + adExecuteNoRecords
strSQL = "SELECT Last_Insert_ID();"
With .Execute(strSQL, , adCmdText)
If Not (.BOF And .EOF) Then
' Found the new ID - build the second Insert SQL string
lngLastAddressID = .Fields(0)
Else
' Abort
End If
.Close
End With
strSQL = "INSERT INTO tbl_address_school (addschool_id_school, addschool_id_address) VALUES (" & lngLastSchoolID & "," & lngLastAddressID & ");"
.Execute strSQL, , adCmdText + adExecuteNoRecords