|
我按照你的程序过了好几遍,一点错误都没有
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
不过,就事论事,既然已经有了保存到第一个表中的值,就应该直接把它们用到第二个sql中。何苦再从第一个表中取回来。随便说说,勿怪。 |
|