Error code 2482 on Access macro

Anonymous
2025-05-16T17:34:50+00:00

I am experiencing error 2482 when trying to run an Access macro that contains a step with an expression. Macro runs fine until that step. Database is in a trusted location, but CurrentProject.IsTrusted=False. Running Windows 11 on PC.

Microsoft 365 and Office | Access | For home | Other

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
Accepted answer
  1. DBG 11,381 Reputation points Volunteer Moderator
    2025-05-16T19:27:17+00:00

    I think, with your help, I'm learning something new. I have not tried a data macro before, but it looks like exactly what I need. I will do some experimenting and get back to you later, if that is OK.

    They're all tools in your arsenal. You just need to choose the correct one to use based on your goals.

    1 person found this answer helpful.
    0 comments No comments

12 additional answers

Sort by: Most helpful
  1. DBG 11,381 Reputation points Volunteer Moderator
    2025-05-16T18:53:46+00:00

    ">

    I created a totaling query on the table (Total: Sum) and created another macro as

    SetLocVar

    Name: Test

    Expression = {Query1]!{SumOfValue1]

    Running the macro produces the same 2482 error message.

    I should note that the database is in a trusted location, but when I examine CurrentProject.IsTrusted (with macro named "AutoExec"), result is False.

    Right. The basic premise is that you can't basically "look into" the values inside a table from within a saved macro, you'll have to use a function to do that (or use a data macro). That is why I recommended using DSum(). Have you tried it yet? Are you not able to use it?

    0 comments No comments
  2. Anonymous
    2025-05-16T19:16:58+00:00

    I think, with your help, I'm learning something new. I have not tried a data macro before, but it looks like exactly what I need. I will do some experimenting and get back to you later, if that is OK.

    0 comments No comments
  3. Anonymous
    2025-05-16T20:17:14+00:00

    Perfect! I can't thank you enough for your help.

    0 comments No comments
  4. Anonymous
    2025-05-16T20:29:53+00:00

    I think the problem here is that an aggregation operator like SUM in a query is qualified by the HAVING operator, not the WHERE operator, i.e. it operates on the aggregated value after grouping.  If you want to, use the WHERE operator to operate on an aggregated value, a subquery would normally be used.  The VBA aggregation operators like DSum operate in the same way as a subquery, so can be used in a macro in the same way that they can be used in a WHERE clause in a query.

    0 comments No comments