Darren D
darren at activebilling.com.au
Wed Nov 14 23:15:02 CST 2007
Hi Borge I am now realising I can get the rs1.RecordCount without 'populating' using rs1.MoveLast and rs1.MoveFirst - Cool - It is in place now But there are occasions where I do need to get to the last record so I can display the description of the last record on the users form EG In code in the line after rs1.MoveLast I have a line that reads Me.lblDisplay.Caption = "Current Run: " & rs!RunDescription Then the next line is .MoveFirst and then after that I do a loop and then I do all the .Update stuff after that Many thanks for your reply Darren -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of pcs at azizaz.com Sent: Thursday, 15 November 2007 2:58 PM To: Access Developers discussion and problemsolving Subject: Re: [AccessD] Getting a Record Count using ADO Darren, In ADO Just execute rs.RecordCount which works with : .CursorType = adOpenKeyset regards Borge ---- Original message ---- >Date: Thu, 15 Nov 2007 11:29:42 +1100 >From: "Darren D" <darren at activebilling.com.au> >Subject: [AccessD] Getting a Record Count using ADO >To: "'Access Developers discussion and problem solving'" <accessd at databaseadvisors.com> > >Hi All > > > >When I use DAO Recordsets I can simply do a rs.movelast and rs.MoveFirst to >populate the rs and then can do an accurate rs.recordCount - Simple > >When using ADO - IF I use the line rs.movelast - I get a strange error about >backward fetching > >"Run Time Error -2147217884(80040e24) > >Rowset does not support fetching backward > >If I rem the line rs.MoveLast - the code works > >Code Snip Below (The real code does some updates etc on a second recordset - >snip not included for that) > >Anyone know about this - Is there a work around - I just want to compare one >rs.recordCount with another rs2.RecordCount and if they differ then do something >- else forget about it > >Make sense? > >Many thanks in advance > >DD > > > > > >'#############This is connecting a an SQL Server dB > >Dim conn1 As New ADODB.Connection > >Dim rs1 As New ADODB.Recordset > >Dim selSQL1 As String > >Dim intRecordCount As Integer > >Dim i As Integer > > > >selSQL1 = "SELECT * from BillRun" > >conn1 = f_SetSQLSVRConnection '<--SQL Server connections set up and passed from >a function here > >conn1.Open > > > >rs1.Open selSQL1, conn1 > > > >intRecordCount = 0 > > > >With rs1 > > If Not rs1.BOF And Not rs1.EOF Then > > 'rs1.MoveLast <---- If I leave this line in - I get the error > > rs1.MoveFirst > > > > Do Until rs1.EOF > > End If > > End With > > rs1.MoveNext > > intRecordCount = intRecordCount + 1 > > Loop > > Else > > End If > >End With > >-- >AccessD mailing list >AccessD at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/accessd >Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com