Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2010
    Posts
    175

    Unanswered: Execute a Macro if the results of an expression meet a criteria

    Hello all.

    I have a form in Access 2010. ON the form is a text box with a control source that I have created an expression for. The expression is an IIF function that returns either "yes" or "no".

    I have also created a macro. If the result of the expression is "no" as described above, I want the macro to execute.

    What is the easiest way to pull this off?

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Populating the Textbox with an expression in the Control Source is not going to cause any event to fire, so you'll need to find another way to run the Macro. How, exactly, does the expression work? If it's based on a value entered in another Control on the Form, you could possibly use an event of that Control (maybe the AfterUpdate event?) to initiate the Macro.

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Oct 2010
    Posts
    175
    Okay I took a shot and added an after update event to the textbox that the expression is changed by....the macro worked successfully, but I only want the macro to then execute if the value of that textbox is a certain value.

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Quote Originally Posted by akanick View Post

    ...the macro worked successfully, but I only want the macro to then execute if the value of that textbox is a certain value...
    So use an If...Then...EndIf construct and only execute the Macro if the Control holds that certain value.

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    Join Date
    Oct 2010
    Posts
    175
    How do I do that without using SQL code? I'm not very familiar with it

    Oh Wait, do you mean construct this within the Macro itself?
    Last edited by akanick; 03-14-14 at 16:06.

  6. #6
    Join Date
    Oct 2010
    Posts
    175
    Okay, here's what I came up with. Am I on the right track?
    Attached Thumbnails Attached Thumbnails macro2.jpg  

Posting Permissions

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