WebFeb 8, 2013 · Dim rs as RecordSet Set rs = me.RecordSet Dim RecCount as long RecCount = rs.RecordCount Example 2: Dim rs as RecordSet Set rs = me.RecordSet Dim RecCount as long rs.MoveLast 'do a MoveLast before getting the Record Count RecCount = rs.RecordCount Example 3: OR... is it an issue when you use an SQL statement to … WebFeb 8, 2013 · Dim rs as RecordSet Set rs = me.RecordSet Dim RecCount as long RecCount = rs.RecordCount Example 2: Dim rs as RecordSet Set rs = me.RecordSet Dim RecCount as …
How to use VBA to get the correct number of records in a ADO recordset
WebMar 27, 2008 · Set rst = CurrentDb.OpenRecordset(LockSQL) recordexists = rst.RecordCount MsgBox "The number of records you are about to delete is " & recordexists & "." " Click the ok button to proceed", vbOKCancel, vbDefaultButton2 If Nz(recordexists, 0) > 0 Then 'code will delete the records that the user has selected.............. End If End If End Sub WebSep 16, 2012 · For some reason the record count for one of my sql-queries return -1. I have the exact same connection and query above, which returns the correct number of records. sqlRS.RecordCount returns the correct number of records, while sqlrs_c.RecordCount returns -1 (but ir really returns 5 to the worksheet). Thanks, Code: isher setter boots
ADO, RecordSet and RecordCount = -1?????
WebSep 8, 2024 · Set oRS = CreateObject ("ADODB.Recordset") oRS.CursorLocation = adUseClient oRS.Open sSQL, cn. ADO 's recordcount property returns -1 when ADO … WebJul 17, 2003 · When ever I read the RecordSet.RecordCount property I get a negative number returned. I know the record exists, but the count is a negative number. Code: Private Sub cmdExecute_Click () Dim myConnection As ADODB.Connection Dim myRecordset As ADODB.Recordset Set myConnection = New ADODB.Connection WebSep 5, 2013 · Now the .RecordCount in rst (1) shows the correct record count and loops as many times. However, the .RecordCount in rst (2) always show that there is only 1 record - which is wrong. I tried to execute a SQL query to create a new table using the same query I used to create the recordset and it showed the correct number of records. isheri olowora postal code