以下是引用aydl1014在2006-10-27 10:04:00的发言:
还可以这样写,代码比较简练
CurrentProject.Connection.Execute "DELETE * FROM 临时表;"
CurrentProject.Connection.Execute "INSERT INTO 临时表(表名) SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],1)<>'~') AND (Left$([Name],4) <> 'Msys') AND Name<>'临时表'AND (MSysObjects.Type)=1 ORDER BY MSysObjects.Name;"
CurrentProject.Connection.Execute "update 临时表 set 记录数=dcount('[编号]',表名);"
DoCmd.OpenTable "临时表"
这段代码在我的机上运行时出现如下问题提示框:
***********************************************
Runtime'-2147217900(80040e14):'
Unknown
***********************************************
我按了调试键后,下面这句代码用黄色高亮显示:
******************************************************
CurrentProject.Connection.Execute "update 临时表 set 记录数=dcount('[编号]',表名);"
************************************************************
我机上的完整代码是:
Option Compare Database
Private Sub Command0_Click()
CurrentProject.Connection.Execute "DELETE * FROM 临时表;"
CurrentProject.Connection.Execute "INSERT INTO 临时表(表名) SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],1)<>'~') AND (Left$([Name],4) <> 'Msys') AND Name<>'临时表'AND (MSysObjects.Type)=1 ORDER BY MSysObjects.Name;"
CurrentProject.Connection.Execute "update 临时表 set 记录数=dcount('[编号]',表名);"
DoCmd.OpenTable "临时表"
End Sub
*************************************************************************
请问如何纠正?谢谢!
[此贴子已经被作者于2006-10-27 11:13:31编辑过]
|