Need help with "Compile Error: Type Mismatch"

Anonymous
2024-10-08T15:46:13+00:00

I have a procedure to export some queries from Access to Excel. It worked yesterday afternoon, but today it's giving me an error. I'm pretty sure I didn't make any changes since the last time it worked, and the type mismatch isn't making sense to me. Here's the portion of code that's raising the error:

I have variable declaration earlier in the procedure:

Only the 3rd query def is causing an error even though it follows the same format as the previous 2. What's the problem here?

Microsoft 365 and Office | Access | For business | 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

11 answers

Sort by: Most helpful
  1. DBG 11,531 Reputation points Volunteer Moderator
    2024-10-08T16:22:30+00:00

    How exactly did you declare RawTOL?

    0 comments No comments
  2. Anonymous
    2024-10-08T16:34:13+00:00

    In the 2nd screenshot: "RawTOL As QueryDef". Same as the other two queries.

    0 comments No comments
  3. DBG 11,531 Reputation points Volunteer Moderator
    2024-10-08T16:50:10+00:00

    In the 2nd screenshot: "RawTOL As QueryDef". Same as the other two queries.

    Just as a test, try changing that to:

    RawTOL As **DAO.**QueryDef

    0 comments No comments
  4. Anonymous
    2024-10-08T17:10:37+00:00

    Still raising the same error

    0 comments No comments
  5. George Hepworth 22,220 Reputation points Volunteer Moderator
    2024-10-08T18:11:38+00:00

    What are the data types of "LeaveDate" and "ExportMonth"

    0 comments No comments