Private Sub Command0_Click()
Dim sql As String
Dim rst As ADODB.Recordset
Dim iId As Integer
Set rst = New ADODB.Recordset
sql = "insert into test1(test1id,test1name) values(1,'aaa')"
DoCmd.RunSQL sql
sql = "select test1id,test1name from test1"
rst.Open sql, CurrentProject.Connection, 2, 4 ///我用的是adp
rst.MoveLast
iId = rst("test1id")
sql = "insert into test2(test2id,test2name) values('" & iId & "','a')"
DoCmd.RunSQL sql
End Sub