Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Run Macro based on query (2003)

    Is it possible to run a macro based on whether a query equals "True". I have a query that runs a test and returns either True or False. I'd like to run a macro if the results are True and do nothing if it's False.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Run Macro based on query (2003)

    A query returns one or more records, it doesn't return a value. Can you explain in more detail what you mean?

  3. #3
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run Macro based on query (2003)

    SELECT IIf([Client Version].[Version_ID]=[Version].[Version_ID],"True","False") AS Test
    FROM [Client Version], Version;

    I'm trying to test the version of the users front end against the newest version. If it is true, that means the user has the most up to date copy, otherwise if it's false, then I'd like to run a macro that informs the user via a message box to contact me to get the new version, and then automatically closes without letting the user proceed. I've got the macro complete, I'm just not certain on how to complete the other.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Run Macro based on query (2003)

    In the first place, you can simplify the query to

    SELECT ([Client Version].[Version_ID]=[Version].[Version_ID]) AS Test
    FROM [Client Version], Version;

    Open your macro in design view.
    Make sure the Condition column is displayed in the macro design window.
    Enter the following condition in the first row:

    DLookup("Test","QueryName")=False

    where QueryName is the name of your query.
    Enter an ellipsis ... in the Condition column in the other populated rows of the macro. This tells Access that the same condition applies.

    If you run this macro, the actions will only be executed if the condition is true, i.e. if the DLookup function returns false.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •