0
我有一个带有SQL表和过程的Access前端。我试图找出最好的方法来获得一个消息框,告诉用户有多少记录是通过SQL过程添加的。减去VBA变量
Private Sub cmdAddReconciliationRecords_Click()
reccount1
AddReconciliationRecords
Reccount2
End Sub
Public Sub reccount1()
Dim db As DAO.Database
Dim Rec1 As Integer
Set db = CurrentDb
Rec1 = DCount("*", "dbo_reconciliation")
msgBox Rec1 & "Records" 'I will take this out once I get it to work
End Sub
“接着,该流程AddReconciliationRecords运行追加记录
Public Sub Reccount2()
Dim db As DAO.Database
Dim Rec1 As Integer
Dim rec2 As Integer
Dim tot As Integer
Set db = CurrentDb
rec2 = DCount("*", "dbo_reconciliation")
tot = rec2 - Rec1
msgBox tot & " records added."
End Sub
我得到的结果是记录,而不是我开始与记录编号和记录编号我之间的差额总数以...结束。 谢谢大家的帮助。
在第二子,你永远不会默认初始化'Rec1'so它是0,所以你总是在做'REC2 - 0'。 – litelite
为什么不只是'AddReconciliationRecords'告诉你它插入了多少记录? – litelite
没关系,我在发帖后5分钟就想出了答案,我一直在努力研究如何获得附加记录的记录数。 – Matt