Knowledgebase
[QODBC-ALL] Access VBA Recordset.RecordCount Returns "-1" After QuickBooks Enterprise 25 Upgrade
Posted by William - QODBC Support on 07 October 2026 07:44 AM

[QODBC-ALL] Access VBA Recordset.RecordCount Returns "-1" After QuickBooks Enterprise 25 Upgrade

Problem Description:

After upgrading to QuickBooks Enterprise 25, code that previously returned a valid record count from a QODBC-connected Access VBA recordset now returns -1 (or "-1^"). The query itself works - data can be appended and read - but the RecordCount property fails. This was resolved by setting the ADO Recordset's CursorLocation to adUseClient (3).

Affected products: QODBC Desktop, QuickBooks Enterprise 25, MS Access VBA
Expected outcome: After setting CursorLocation to adUseClient on the ADO Recordset, RecordCount returns the correct value.

Symptoms:

  • A VBA recordset connected to QODBC via Access returns -1 or "-1^" when the RecordCount property is read.
  • The query executes successfully, and data can be appended, modified, or retrieved - only RecordCount is wrong.
  • The issue appeared after upgrading from an older QuickBooks Enterprise version (e.g., v18) to version 25.
  • The same code works correctly on older versions of QuickBooks Desktop.

Cause:

The ADO Recordset's default cursor type does not support returning a record count. In older versions of QuickBooks, the server-side cursor happened to return accurate counts despite the default settings. With QuickBooks Enterprise 25, the change in how data is returned means RecordCount falls back to the ODBC driver's default behavior - which returns -1 for server-side cursors.

Solution: Set the CursorLocation property to client cursor (value 3 / adUseClient) on the ADO Recordset before opening it.

Note

This is tracked internally as B01800 on the QODBC bug list. The fix applies at the ADO client level and works with all QODBC versions.

Environment:

ProductVersion / Detail
QODBC Desktop All versions (affected when connected to QB Enterprise 25)
QuickBooks Enterprise Version 25+
MS Access VBA with ADO Recordset

Solution:

Set the CursorLocation property of your ADO Recordset to adUseClient (3) after creating the recordset object and before opening it.

' Create the recordset object
Set rst_QB_cust = New ADODB.Recordset

' Set CursorLocation to client cursor BEFORE opening
rst_QB_cust.CursorLocation = 3

' Now open with your connection string
rst_QB_cust.Open strSQL, sConString, adOpenDynamic, adLockOptimistic

' RecordCount now returns the correct value
Debug.Print rst_QB_cust.RecordCount

SQL Examples:

The SQL query itself does not need to change - this is a VBA/ADO configuration issue, not an SQL issue.

strSQL = "SELECT ListID, FullName FROM Customer WHERE IsActive = 'True'"
rst_QB_cust.Open strSQL, sConString, adOpenDynamic, adLockOptimistic

Example Scenarios:

Before the fix:

An Access VBA application connected to QuickBooks via QODBC worked fine with QB Enterprise v18. After upgrading to QB Enterprise 25, the RecordCount returned -1 and downstream code failed.

After the fix:

The CursorLocation was set to 3 on the ADO recordset before opening it. RecordCount now returns the correct number of records.

Additional Notes:

  • adUseClient = 3: The client-side cursor processes results locally in memory, which allows RecordCount to be accurate at the cost of slightly more memory usage for large recordsets.
  • This is a VBA/ADO best practice: Setting CursorLocation = adUseClient should always be used when you need an accurate RecordCount from any ODBC data source, regardless of QuickBooks or QODBC version.

How to Match 32-bit and 64-bit DSNs for QODBC QODBC Connection Strings for MS Access VBA

Keywords:

QODBC RecordCount CursorLocation ADO Access VBA -1 QuickBooks Enterprise 25 B01800 adUseClient ODBC
(0 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please complete the captcha below (we use this to prevent automated submissions).