Results 1 to 3 of 3
  1. #1
    MikeWaring is offline Novice
    Windows 7 64bit Access 2002
    Join Date
    Dec 2010
    Posts
    28

    Question Using Condition in Stop Macro

    I hope someone can help me - I'm trying to write a macro that stops or runs depending on the value of a certain field in the related form. This Conditional field ("ORDER_TOTAL") in question is a calculated total value of all the value of the records in the form.



    In detail, the form contains a list of all products that require to be ordered from a supplier. If the "ORDER_TOTAL" value (ie the total of the value of all the lines) is below £1000, the macro will stop but if the "ORDER_TOTAL" value is above £1000, the macro will send a csv file of the form contents.

    I've written many Stop macros using the IsNull function without any problems, but this one has me stumped.

    I'm clearly missing something simple here..

    Here's the condition I've tried to use
    Code:
     ([Forms]![FLAG UP LOW STOCK - AMTECH]![Order_Total])<1000
    , but the macro only runs the "Stop" action. I've also tried the ">1000" but it still only runs the Stop actions.

    I'm wondering if the problem is to do with the fact that the control field is a calculated one so as such isn't really part of the form contents.
    All ideas would be welcome. I have no clue about VBA so I need to do this with a macro.
    Thanks in advance,
    Mike

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Code should be able to reference control that has calculated value.

    I use only VBA but can sometimes debug macros, if you provide the file. Follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    MikeWaring is offline Novice
    Windows 7 64bit Access 2002
    Join Date
    Dec 2010
    Posts
    28
    Hi, thanks for the quick response. In the meantime I've been trying different things and what appears to be happening is that if the form is already open and displaying on the screen the macro runs as it should. But if I let the macro open the form, the macro doesn't work.

    What is more puzzling is that if I call a macro to open the form as the first action of the stop macro (even before the "Open Form" part of the stop macro), the stop macro still doesn't work. I've even tried to add "Repaint" action, but it still doesn't work.

    So I'm completely baffled. The macro doesn't actually error out, it just seems to default to the "Stop" condition if the form isn't already open. When it is, the macro performs both conditions properly, depending on the £ value in that control field.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Autokey macro will not print reports using a condition
    By boywonder in forum Programming
    Replies: 2
    Last Post: 11-07-2011, 10:48 AM
  2. Start and Stop times where condition true
    By cheshire_smile in forum Queries
    Replies: 3
    Last Post: 07-05-2011, 09:59 PM
  3. where condition within a macro
    By kstyles in forum Reports
    Replies: 3
    Last Post: 04-08-2011, 03:58 PM
  4. Macro Condition
    By eww in forum Programming
    Replies: 5
    Last Post: 08-27-2010, 10:59 AM
  5. Stop SendObject Macro
    By OpsO in forum Import/Export Data
    Replies: 1
    Last Post: 08-19-2010, 09:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums