|
下面这段程序在运行时出现"microsoft jet 数据库引擎找不到输入表或查询表"rsl2",确定它是否存在,以及名称的拼写是否正确",程序停止在DSUM(),
我检查过,表的名字正确无误,不知是因为什么出错?
请指点迷津,谢谢!
Public Sub 补填底价() Dim varBalance As Currency, strLedger As String, 表2 As String Dim rs1 As ADODB.Recordset, rsl2 As ADODB.Recordset Set rs1 = New ADODB.Recordset Set rsl2 = New ADODB.Recordset '指定rs1的联结数据库为目前打开的数据库 rs1.ActiveConnection = CurrentProject.Connection rsl2.ActiveConnection = CurrentProject.Connection On Error GoTo 错误式 strLedger = InputBox("请输入你要补余额的分类帐表的名称", "系统提示", "销售日报DT") 表2 = InputBox("请输入你要查询的分类帐表的名称", "系统提示", "底价变动") '使用open方法打开刚生成的表「??分类帐」 rs1.Open strLedger, , adOpenKeyset, adLockOptimistic, adCmdTable rsl2.Open 表2, , adOpenKeyset, adLockOptimistic, adCmdTable '先设余额等于零 varBalance = 0 '使用Do Loop循环在表记录集合中逐笔往下计算底价 Do Until rs1.EOF 'rs1.CancelUpdate varBalance = DSum("rsl2!单价", "rsl2", "rsl!日期 < rsl2!日期 And rsl!机型 = rsl2!机型") rs1("底价") = varBalance rs1.Update rs1.MoveNext Loop MsgBox "底价字段已替你补好了,你不必自己计算" rs1.Close rsl2.Close Set rs1 = Nothing Set rsl2 = Nothing DoCmd.SelectObject acTable, strLedger, True DoCmd.OpenTable strLedger, acViewNormal, acEdit DoCmd.GoToControl "底价" 错误式: If Err.Number <> 0 Then MsgBox "错误讯息:" & Err.Description & Err.Number Else MsgBox "没有错误发生,Err代码是:" & Err.Number End If Exit Sub End Sub
[此贴子已经被作者于2004-2-24 10:39:10编辑过] |
|