CurrentDb.RecordsAffected返回0.为什么? [英] CurrentDb.RecordsAffected returns 0. Why?

查看:105
本文介绍了CurrentDb.RecordsAffected返回0.为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我将RecordsAffected与CurrentDb.Execute一起使用,它将始终返回0.如果我首先创建一个Database对象的实例,则它可以正常工作.为什么?

If I use RecordsAffected with CurrentDb.Execute, it always returns 0. If I first make a instance of a Database object it works properly. Why?

喜欢这个:

Dim Db As Database
Set Db = CurrentDb

Db.Execute "DELETE * FROM [Samples] WHERE Sample=5"
If Db.RecordsAffected = 0 Then
  MsgBox "Error"
End If

代替:

CurrentDb.Execute "DELETE * FROM [Samples] WHERE Sample=5"
If CurrentDb.RecordsAffected = 0 Then
  MsgBox "Error"
End If

我正在使用Access 2007和Microsoft Office 12.0 Access数据库引擎对象库.

I'm using Access 2007 and the Microsoft Office 12.0 Access database engine Objects Library.

推荐答案

每次使用CurrentDB时,它都是一个新实例.

Each time you use CurrentDB, it is a new instance.

这篇关于CurrentDb.RecordsAffected返回0.为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆