Access VBA7 Error 5: Invalid Procedure Call or Argument On String Comparison

LUIS VL 1 Reputation point

Hi! I am having the very same error reported in this post at MSDN Forum.

The problem arouse in a Database that was working fine until yesterday, but it happens in any database, including newly created ones.

Since MSDN forum isn't working anymore, and the answers there were a bit random, I am opening a new post here in hope that someone can give an answer.
It is likely that my problem is caused by a bug in MS Access code, though, so I'm not keeping high expectations. Still, maybe someone runs into the same problem, and hopefully I can help him/her devise a workaround.

Steps to reproduce the problem:

  • Create a new .accdb file (Microsoft Access Database)
  • Alt+F11 to open VBA7 editor
  • Alt+G to open Inmediate window
  • At inmediate window, write this code: Debug.print "a" = "a"
  • Press Return .The code executes and throws error 5: Invalid procedure call or argument
  • Create a new module
  • create a "sub" procedure like this: Option Compare Binary
    Option Explicit Sub test()
    Debug.Print "a" = "a"
    End Sub
  • Execute the Sub (by pressing F5 while in the function or writing test at Inmediate Window and pressing Enter.
  • Same error
  • In the module, change Option Compare Database to Option Compare Binary or Option Compare Text
  • Now, on execution, everything works just fine.

So, the question here is: why is it happening, now?
I can change all the modules to use Option Compare Text or Binary, but why does it fail with Option Compare Database, which is the default option?

System Information:
Microsoft Windows 10 Pro - Version 10.0.19044 compilation 19044 - 64 bits

System Language: Spanish - Spain

Access Version:
Version 2207 (compilation 15427.20210)
--> Microsoft® Access® for Microsoft 365 MSO (version 2207 compilation 16.0.15427.20166) 32 bits

Access Development
Access Development
Access: A family of Microsoft relational database management systems designed for ease of use.Development: The process of researching, productizing, and refining new or existing technologies.
842 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Gustav 712 Reputation points MVP

    I can't reproduce this.
    So, try to run an Office repair.