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. Anonymous
    2022-08-08T08:15:20+00:00

    LarryA15,

    Try "adOpenStatic" instead. If "adOpenKeySet" cannot work.

    Also try to make sure ADO is reference the the VBA editor.

    Also, try 2.8 or 6.1 instead of 2.1. 2.1 is too old.

    0 comments No comments
  2. Anonymous
    2022-08-08T17:56:30+00:00

    Changing 2.1 to 6.1 did the trick. Thanks to everyone who responded.

    0 comments No comments