Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Mar 2002
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Control Source (Access2000)

    Hi
    Is it possible to have a text box with an equation statement in the Control Source property box but also be able to get the equation result into a Table.
    E.g.On a form I have Textbox3 =[Textbox1]+[Textbox2] in the Control source, but I would like the answer to go into Table1's Total column along with textbox2 and textbox2's data. Is this possible or do I need some code?
    Thanks
    John

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Control Source (Access2000)

    You would need code, but it isn't advisable. Any time you can calculate the value, you should not store it in a table. The problem is that if one of the values that created it gets changed, the calculated value won't change to match.
    Charlotte

  3. #3
    New Lounger
    Join Date
    Mar 2002
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Control Source (Access2000)

    I see that make sense. Say that I have three columns in a table CostA, CostB and totalC is there anyway at the totalC cloumn would add these two values (CostA and CostB) together in the table from?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Control Source (Access2000)

    To repeat what Charlotte wrote, you shouldn't have a TotalC column in the table.The preferred way is as follows:
    <UL><LI>Create a query based on the table.
    <LI>Add CostA and CostB (and any other field you need) to the query grid.
    <LI>Create a calculated field TotalC:[CostA]+[CostB] in the query grid.
    <LI>Save the query and use it as record source for forms and reports instead of the table; you can also build new queries on it.[/list]This way, TotalC will always be up-to-date. If you put a field TotalC into the table, you run the risk that CostA or CostB gets changed, but TotalC doesn't. Access doesn't have triggers that fire automatically when a value in a table is changed; you can only do this in a form. Besides, storing the result of a calculation in a table means that you are storing redundant information.

    (There is one exception: if you have a very complicated expression that would take an inordinate amount of time to recalculate everytime, you might store the result in the table. But a simple addition hardly merits that description...)

  5. #5
    New Lounger
    Join Date
    Mar 2002
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Control Source (Access2000)

    Hans
    I did not know that you could calculate in a Querys, you have been a great help
    Thanks
    John

Posting Permissions

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