给你参考一下:The following example uses the MoveLast method to populate the Recordset object so the number of records can be counted. The MoveFirst method then moves the current record pointer to the first record in the Recordset object. The procedure prompts the user to enter a number, then moves that number of records forward.Sub MoveThroughRecords() Dim dbs As Database, rst As Recordset, intI As Integer Dim strNumber As String
' Return reference to current database. Set dbs = CurrentDb Set rst = dbs.OpenRecordset("Products") ' Populate Recordset object. rst.MoveLast ' Return to first record. rst.MoveFirst ' Get number smaller than number of records. strNumber = InputBox("Please enter a number less than " _ & rst.RecordCount & ".") ' Move specified number of records. For intI = 1 To strNumber rst.MoveNext Next intI Debug.Print rst!ProductName rst.Close Set dbs = Nothing End Sub
算了吧做一个sql语句不是轻松的多set record=conn.execute("select count(*) as resultcount from 表明")int recordCount=record("resultcount")搞定阿
执行Data1.Recordset.MoveLast后Data1.Recordset.recordcount 才正确。
这个问题以前我也困惑过
事实上dao就是这样的
Dim dbs As Database, rst As Recordset, intI As Integer
Dim strNumber As String
' Return reference to current database.
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Products")
' Populate Recordset object.
rst.MoveLast
' Return to first record.
rst.MoveFirst
' Get number smaller than number of records.
strNumber = InputBox("Please enter a number less than " _
& rst.RecordCount & ".")
' Move specified number of records.
For intI = 1 To strNumber
rst.MoveNext
Next intI
Debug.Print rst!ProductName
rst.Close
Set dbs = Nothing
End Sub
算了吧做一个sql语句不是轻松的多set record=conn.execute("select count(*) as resultcount from 表明")int recordCount=record("resultcount")搞定阿
------------------------------------怎么让你相信伤了你的心的我的心好伤心