type mismatch error in Access after upgrading to Office 2021

Anonymous
2022-07-23T16:31:54+00:00

After recently upgrading from Office 2010 to Office 2021, a report fails with a type mismatch error. I've made no changes to the code, and it still works in Access 2010. In addition to the code below, RecCount is declared Public Integer.

The references are: Visual Basic For Applications; Microsoft Access 16.0 Object Library; OLE Automation; Microsoft Outlook 16.0 Library; Microsoft ActiveX Data Objects 2.1 Library.

Any suggestions would be greatly apreciated.

Microsoft 365 and Office | Access | Other | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

12 answers

Sort by: Most helpful
  1. George Hepworth 22,295 Reputation points Volunteer Moderator
    2022-07-23T20:22:27+00:00

    You've commented out this line:

    ' MsgBox "RecCount = " & RecCount

    What happens if you replace it with

    MsgBox "RecCount = " rst.RecordCount

    before attempting to assign that recordcount to the variable.

    0 comments No comments
  2. Anonymous
    2022-07-23T20:51:48+00:00

    Same problem.

    It's erroring on the RecCount = rstRec.RecordCount statement.

    0 comments No comments
  3. George Hepworth 22,295 Reputation points Volunteer Moderator
    2022-07-24T00:05:59+00:00

    So that appears to confirm that the problem is in the properties of the ado recordset in the current version of Access. There was a recent bug that might be related to this. I have to track it down, though, as it's been a few days and I don't have the reference at hand. While I search, perhaps someone will recall the bug.

    0 comments No comments
  4. ScottGem 68,780 Reputation points Volunteer Moderator
    2022-07-24T01:45:39+00:00

    Do yiou have Option Explicit set? Where do you Dim RecCount?

    0 comments No comments
  5. Anonymous
    2022-07-24T03:20:16+00:00

    At the beginning of the module.

    Option Compare Database

    Option Explicit

    Public NxtPgNum, RecCount As Integer, MlgRate As Currency

    0 comments No comments