Query too complex Bad DLL calling convention - error 49
If you receive either or both of these errors while running VBA code and the error message does not seem to apply to your situation, here's another possible resolution.
Both of the above errors can legitimately be caused by the error description but I had a custom VBA function which was working for weeks and then after some edits started crashing with the above two errors. The first error showed up in my error handler message box but if I ran the offending function call manually I received the second error instead. Neither message seemed relevant to my code. After several attempts to resolve it by replacing the queries used in the function and doing the repair/compact routine, I was stuck. The function itself would complete correctly without going into its error handling routine but when control returned to the calling procedure it immediately errored.
What worked was that I exported a copy of the module as a backup and then copied and pasted the offending function into Word. Then I created a new module in the database and pasted lines of code from Word back into the new module, skipping blank lines and extra comments (ie. not a wholesale copy and paste, but several 1-3 line copies and pastes.) I saved the new module with the "new" function and then deleted just that function from the original module. Saved everything and magically now it works!
Wouldn't be too big a stretch to imagine this could work with other illogical error messages too... Anyone know what could get into a piece of code that would make it go wacky like that?