Arthur Fuller
fuller.artful at gmail.com
Sun Mar 24 12:15:20 CDT 2013
In my Sunday morning "Nothing is True, Question Everything" mood, I was playing around with recordsets and wrote this little test of RecordCount. Because I've always assumed it would be bad, coded something like this: <vba> With rs If .bof or .eof then Msgbox end if .MoveLast .MoveFirst debug.print .RecordCount ' or do something with it End With </vba> So instead I tried this: <vba> Dim intCount As Integer Dim rs As DAO.Recordset Set rs = Me.RecordsetClone With rs 'This suggests that the common movelast command is unnecessary. 'The record count is the same before and after Debug.Print "Count Before Move: " & .RecordCount .MoveFirst .MoveLast Debug.Print "Count After Move: " & .RecordCount intCount = .RecordCount End With Me.txtCount = intCount rs.Close Set rs = Nothing </vba> It appears that the recordset knows how large it is even without the MoveLast command. Is the wisdom a myth? Or maybe that an old bug finally got fixed? I'm using 2007, does that make a difference? Maybe it has something to do with the size of the recordset, as in the case of a form bound to a table with a million rows. Any thoughts? -- Arthur