# Re: 补充说明

Posted by 纪文和 on May 08, 1999 at 22:23:20:

In Reply to: Re: 如何得知资料库总比数 posted by 小呆 on May 08, 1999 at 14:24:16:

: : 如何取得资料库总比数

: Dim WS As Workspace
: Dim db As Database
: Dim rs As Recordset
: Set WS = DBEngine.Workspaces(0)
: Set db = WS.OpenDatabase("h:\gb\PGB-id.mdb", False, False) '开启档案
: Set rs = db.OpenRecordset("gbookid") '选择资料表使用者资料
: Debug.Print rs.RecordCount '总笔数
: rs.Close '关毕
: db.Close '关毕
: WS.Close

Set rs = db.OpenRecordset("gbookid") '选择资料表使用者资料
这时, rs.RecordCount 是不会正确的 (可能只是1)
必须先 rs.movelast 再
Debug.Print rs.RecordCount '总笔数

以下是 Msdn Library 中对 Recordcount 的一段说明
Use the RecordCount property to find out how many records in a Recordset or TableDef object have been accessed. The RecordCount property ((doesn't)) indicate how many records are contained in a dynaset-, snapshot-, or forward-only－type Recordset object until all records have been accessed. Once the last record has been accessed, the RecordCount property indicates the total number of undeleted records in the Recordset or TableDef object. To force the last record to be accessed, use the ((MoveLast)) method on the Recordset object. You can also use an SQL Count function to determine the approximate number of records your query will return.

Follow Ups: