Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2009
    Posts
    6

    Unanswered: Stopping a Macro (Conditinal Macros)

    Hi,

    I've got a Macro assigned to a button on a form which is a query output. When the user clicks on the button it reads a value from a field and subtracts 150. It puts the new value back into that field.

    I have done this with a Macro

    The Macro looks like this:

    GoToControl Points Balance
    SetValue [Forms]![frm_qry_choose_gift]![Point Balance], [Forms]![frm_qry_choose_gift]![Point Balance]-150

    I'm looking to get some sort of conditional rule in there which reads the users points value and if they have less than 150 runs another Macro that tells then they cannot continue (and then stops the current macro).

    Can anyone offer advice getting the conditional rule in there? I could use code but for this scenario it has to be a macro.

    The pseudocode I want to follow is:

    runMacro
    If button1 is clicked then
    read guest_points
    if guest_points is less than 150 then
    run errormessageMacro
    else
    continue running the subtraction and field update to remove 150 points.

    Any help is appreciated,

    Many thanks

    Gareth

  2. #2
    Join Date
    May 2005
    Posts
    1,191
    What you'd like to do can be easily accomplished with VB. On the OnClick event of the button, insert some code like:
    Code:
    if [Forms]![frm_qry_choose_gift]![Point Balance] > 150 then
        [Forms]![frm_qry_choose_gift]![Point Balance] = [Forms]![frm_qry_choose_gift]![Point Balance] - 150
    else
        msgbox "Value is too low.",vbCritical, "Invalid"
    End If
    Me.Geek = True

  3. #3
    Join Date
    Jan 2009
    Posts
    6
    Thanks mate,

    I'm going to try the code. I managed to get the Macro to work as well using the ... characters on several lines in the Macro.

    I'm assuming with the code I can do a lot more and expand it into what I want to do. The macro seemed the easiest thing to do as I didn't have the time to look into the code.

    Gareth

  4. #4
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Time for you to switch to VBA and leave macros behind
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

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