Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2009
    Posts
    10

    Unanswered: Allow circular calculations in simple form??

    My form has a simple select query as source. I want to type in data into any two of three related fields and have results show in the other. For simple example, My form shows:
    A= my_data
    B= my_data
    C= result_data
    In the query; C=A+B, A=default data, B=default data and the
    form displays all data and calculates C fine...

    However, the form won't allow entry of a calculated field (which makes sence) such as C above (form just beeps when I try to enter/delete data in text box). And if I set A=C-B or B=C-A in query I get circular error....which also makes sence....How can I get the form/query to simply accept any two inputs and calculate the missing third??? Thanks in advance, Al

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    VBA. Get rid of your formulas from the three text boxes. AfterUpdating any of them, have VBA calculate the associated values.
    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

  3. #3
    Join Date
    Apr 2009
    Posts
    10
    So use event builder from properties in VBA and not calculate from a query?

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    I think this is going to have to be done in VBA as StarTrekker suggested, not in a query, as there are too many variations. If a field is calculated in a query, you cannot edit it or enter data directly into the textbox that displays it in a form. Even doing this in code presents problems. You have to, as always, take into account that the user may make a mistake.

    What are you going to do if the user enters two fields and the third one is calculated, and then they change their mind and change one of the fields?

    Say that

    A = 6
    B = 10
    C = 16

    Now the user changes A to 4. You could re-calculate, but which of the other two fields, B or C, do you re-calculate so that the equation balances again? Do you change B to 12 or do you change C to 14? You see the problem?

    One answer, I suppose, is that if all three fields are populated and you change one of them, you could reset the other two to Null, requiring, essentially, that the user goes thru the entire process again.

    But you need to decide how you want to do this before you can go any further.
    Last edited by Missinglinq; 11-01-09 at 17:24.
    Hope this helps!

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

    All posts/responses based on Access 2003/2007

Posting Permissions

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