From: Jamo on

--
Center for technica education


"Linq Adams via AccessMonster.com" wrote:

> John's advice is spot on, of course, and should be followed in the vast
> majority of cases, including the scenario you have here. In the very few
> cases where storing a calculated value is necessary, you have to move the
> calculation to somewhere other than the Control Source for the textbox, so
> that the Control Source can be a field in the underlying table and theresults
> stored in that field.
>
> If, for instance, you were adding the values of two textboxes together,
> txtFieldA and txtFieldB, you'd do something like this, in the AfterUpdate
> event of each of them:
>
> Private Sub txtFieldA_AfterUpdate()
> Me.txtTotal = Nz(Me.txtFieldA, 0) + Nz(Me.txtFieldB, 0)
> End Sub
>
> Private Sub txtFieldB_AfterUpdate()
> Me.txtTotal = Nz(Me.txtFieldA, 0) + Nz(Me.txtFieldB, 0)
> End Sub
>
> --
> There's ALWAYS more than one way to skin a cat!
>
> Answers/posts based on Access 2000/2003
>
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/201005/1
>
> .Ling
I am following John advise and it sound like if I try to do whated I
started to do,it gets too hairy
>
From: Jamo on

--
Center for technica education


"John W. Vinson" wrote:

> On Sat, 8 May 2010 06:06:04 -0700, Jamo <Jamo(a)discussions.microsoft.com>
> wrote:
>
> > Thank you so much for the information. I will delete that field out of
> >the table and create a report to do the total calculation, however for my own
> >curosity can that be done what I was trying to do in a form? I will follow
> >you advice and proceed from here
>
> Well, you can't do calculations in tables - but you have at least three other
> choices!
>
> You can do a calculation in a Query by just typing the calculation expression
> in a vacant Field cell:
>
> Total: [FieldA] + [FieldB]
>
> Or you can display a calculation on a Form by putting an expression in the
> control source property of a form Textbox:
>
> = [FieldA] + [FieldB]
>
> The same technique works on a Report as well.
>
> If you want to sum the value of a field across multiple records, you can also
> do it three (or more) different ways: with a Totals Query; or in the Footer of
> a Form or Report:
>
> = Sum([FieldA])
>
> So you're not losing much by being unable to do the calculation in a table.
>
> SideNote: Access 2010 has <sigh> calculated fields in tables. In reality
> they're a hidden query, and in fact this can be a useful technique, but you do
> need to understand the underlying logic.
> --
>
> John W. Vinson [MVP]
> .John:
Thank you so much,but I think I will follow your suggestion and either
do it in a query or a report.
>
First  |  Prev  | 
Pages: 1 2
Prev: Form Caption Length
Next: Creating a Menu