Controlling the 'On change' event for a numeric control.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SimonG via AccessMonster.com

    Controlling the 'On change' event for a numeric control.

    Hi,

    I would like to be able to compare a control's new value with its old value,
    whenever it is changed by a user.
    The control holds a numeric value, qty_Sold, when this value changes I need
    to check its validity and apply appropriate actions.
    I have tried to do this using the control's 'On Change' event, and the
    properties '.Value' and '.Text' to return the control's old and new values.
    Unfortunately this event triggers on each character entered.
    i.e.
    to change an old value of 1 to a new value 234 would trigger the code
    behind the event three times:
    changing the “1” to a “2” - code triggered;
    user must now re-enter control, position cursor to right of the “2” and
    enter “3” - this triggers code;
    user must now re-enter control, position cursor to right of the “3” and
    enter “4” - this triggers code, for the final (and only required) time.

    Clearly this isn't acceptable to the user, so how do I achieve the required
    comparison only when the user has completed their change?

    I don't know if this effects anything, but the control is in a datasheet sub-
    form.

    Many thanks,
    Simon

    --
    Message posted via AccessMonster.c om


  • Fred Zuckerman

    #2
    Re: Controlling the 'On change' event for a numeric control.

    "SimonG via AccessMonster.c om" <u41095@uwewrot e in message
    news:809bdb88ac 39d@uwe...
    Hi,
    >
    I would like to be able to compare a control's new value with its old
    value,
    whenever it is changed by a user.
    The control holds a numeric value, qty_Sold, when this value changes I
    need
    to check its validity and apply appropriate actions.
    I have tried to do this using the control's 'On Change' event, and the
    properties '.Value' and '.Text' to return the control's old and new
    values.
    Unfortunately this event triggers on each character entered.
    i.e.
    to change an old value of 1 to a new value 234 would trigger the code
    behind the event three times:
    changing the "1" to a "2" - code triggered;
    user must now re-enter control, position cursor to right of the "2" and
    enter "3" - this triggers code;
    user must now re-enter control, position cursor to right of the "3" and
    enter "4" - this triggers code, for the final (and only required) time.
    >
    Clearly this isn't acceptable to the user, so how do I achieve the
    required
    comparison only when the user has completed their change?
    >
    I don't know if this effects anything, but the control is in a datasheet
    sub-
    form.
    >
    Many thanks,
    Simon
    >
    --
    Message posted via AccessMonster.c om
    http://www.accessmonster.com/Uwe/For...ccess/200803/1
    Try using the BeforeUpdate event. Then compare MyField.Value vs
    MyField.OldValu e
    Fred Zuckerman


    Comment

    • SimonG via AccessMonster.com

      #3
      Re: Controlling the 'On change' event for a numeric control.

      Hi Fred,

      I have tried moving the code to the BeforeUpdate event, and using the values
      you describe.

      This does allow the user to change the value, and does not attempt to run the
      code until leaving the control. However this also causes the following error
      message to appear whenever the control is changed:
      "The macro or function set to the BeforeUpdate or ValidationRule property for
      this field is preventing Microsoft Office Access from saving the data in the
      field."
      This error message also appears to stop the code performing its intended
      functions, so unfortunately we do not appear to be any future forward.

      Regards,
      Simon

      --
      Message posted via http://www.accessmonster.com

      Comment

      • Fred Zuckerman

        #4
        Re: Controlling the 'On change' event for a numeric control.

        "SimonG via AccessMonster.c om" <u41095@uwewrot e in message
        news:809d8da67e 9bc@uwe...
        Hi Fred,
        >
        I have tried moving the code to the BeforeUpdate event, and using the
        values
        you describe.
        >
        This does allow the user to change the value, and does not attempt to run
        the
        code until leaving the control. However this also causes the following
        error
        message to appear whenever the control is changed:
        "The macro or function set to the BeforeUpdate or ValidationRule property
        for
        this field is preventing Microsoft Office Access from saving the data in
        the
        field."
        This error message also appears to stop the code performing its intended
        functions, so unfortunately we do not appear to be any future forward.
        >
        Regards,
        Simon
        >
        --
        Message posted via http://www.accessmonster.com
        Please provide the exact code you've set into the BeforeUpdate event. And
        indicate which line is causing the error (Access highlights the line in
        yellow). That will allow us to examine why you're receiving the error
        message.
        Fred Zuckerman


        Comment

        Working...