Updating a calculated value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I can calculate a total value of 3 incomes and show it correctly as "total
income" on the form. "total income" which is a field in file is not updated
when I go to the table view it.
Bob B
 
On Tue, 29 Nov 2005 14:42:02 -0800, "Bob B" <Bob
I can calculate a total value of 3 incomes and show it correctly as "total
income" on the form. "total income" which is a field in file is not updated
when I go to the table view it.
Bob B

Storing derived data such as this in your table accomplishes
three things: it wastes disk space; it wastes time (almost
any calculation will be MUCH faster than a disk fetch); and
most importantly, it risks data corruption. If one of the
underlying fields is subsequently edited, you will have data
in your table WHICH IS WRONG, and no automatic way to detect
that fact.

Just redo the calculation whenever you need it, either as a
calculated field in a Query or just as you're now doing it -
in the control source of a Form or a Report textbox.

John W. Vinson[MVP]
 
Yes I know what you say is true, but I didn't design the data base. Is it
possible to upate the field any way.
 
Yes I know what you say is true, but I didn't design the data base. Is it
possible to upate the field any way.

Yes, if you don't mind having the risk of incorrect data in it.

Use the Form's BeforeUpdate event to "push" the data. Have TWO
textboxes on the form - one with the calculated expression in its
control source (txtCalcTotal), one bound to the table field
(txtTotal). In the Form's BeforeUpdate event put code like

Private Sub Form_BeforeUpdate(Cancel as Integer)
Me!txtTotal = Me!txtCalcTotal
End Sub


John W. Vinson[MVP]
 
I tried what you sugested without success. I have 2 screen dumps of what I
did that I would like to send you. I don't see anyway I can attach them to
this apply. Can I have your e-mail address so I can pass them along to you?
 
I tried what you sugested without success. I have 2 screen dumps of what I
did that I would like to send you. I don't see anyway I can attach them to
this apply. Can I have your e-mail address so I can pass them along to you?

Private email support is provided for paying consulting customers.
Unpaid volunteer support on these newsgroups is free.

If you can, please describe what you did and the error message in
text. Screenshots will be less than helpful in any case.

John W. Vinson[MVP]
 
I created a sample data base for this discussion. The three fields in the
file are INCOME1, INCOME2, AND INCOMETOTAL. In the form view I created 2
text boxes; Text10 & Text16. In the data control source of Text10 I put:
=[INCOME1] + [INCOME2] . In the before update of Text16 I put this
procedure.

Private Sub Text16_BeforeUpdate(Cancel as Integer)
Me!TOTALINCOME = Me!Text10
End Sub

No Errorr messages were received, INCOMETOTAL was not updated
 
John had suggested putting the code in the form's BeforeUpdate event, not
the BeforeUpdate event associated with one of the controls.

As well, if what you've got below is an actual copy-and-paste of your code,
you're referring to the field as TOTALINCOME in code, whereas everywhere
else you're calling it INCOMETOTAL.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Bob B said:
I created a sample data base for this discussion. The three fields in the
file are INCOME1, INCOME2, AND INCOMETOTAL. In the form view I created 2
text boxes; Text10 & Text16. In the data control source of Text10 I put:
=[INCOME1] + [INCOME2] . In the before update of Text16 I put this
procedure.

Private Sub Text16_BeforeUpdate(Cancel as Integer)
Me!TOTALINCOME = Me!Text10
End Sub

No Errorr messages were received, INCOMETOTAL was not updated

John Vinson said:
Private email support is provided for paying consulting customers.
Unpaid volunteer support on these newsgroups is free.

If you can, please describe what you did and the error message in
text. Screenshots will be less than helpful in any case.

John W. Vinson[MVP]
 
Yes I did have that wrong, but when I changed it to ICOMETOTAL the name in
the data sheet it still did not update.

Douglas J. Steele said:
John had suggested putting the code in the form's BeforeUpdate event, not
the BeforeUpdate event associated with one of the controls.

As well, if what you've got below is an actual copy-and-paste of your code,
you're referring to the field as TOTALINCOME in code, whereas everywhere
else you're calling it INCOMETOTAL.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Bob B said:
I created a sample data base for this discussion. The three fields in the
file are INCOME1, INCOME2, AND INCOMETOTAL. In the form view I created 2
text boxes; Text10 & Text16. In the data control source of Text10 I put:
=[INCOME1] + [INCOME2] . In the before update of Text16 I put this
procedure.

Private Sub Text16_BeforeUpdate(Cancel as Integer)
Me!TOTALINCOME = Me!Text10
End Sub

No Errorr messages were received, INCOMETOTAL was not updated

John Vinson said:
On Sat, 3 Dec 2005 15:15:02 -0800, "Bob B"

I tried what you sugested without success. I have 2 screen dumps of
what I
did that I would like to send you. I don't see anyway I can attach them
to
this apply. Can I have your e-mail address so I can pass them along to
you?

Private email support is provided for paying consulting customers.
Unpaid volunteer support on these newsgroups is free.

If you can, please describe what you did and the error message in
text. Screenshots will be less than helpful in any case.

John W. Vinson[MVP]
 
So what's the exact code you're using now, and what event is it running on?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Bob B said:
Yes I did have that wrong, but when I changed it to ICOMETOTAL the name in
the data sheet it still did not update.

Douglas J. Steele said:
John had suggested putting the code in the form's BeforeUpdate event, not
the BeforeUpdate event associated with one of the controls.

As well, if what you've got below is an actual copy-and-paste of your code,
you're referring to the field as TOTALINCOME in code, whereas everywhere
else you're calling it INCOMETOTAL.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Bob B said:
I created a sample data base for this discussion. The three fields in the
file are INCOME1, INCOME2, AND INCOMETOTAL. In the form view I created 2
text boxes; Text10 & Text16. In the data control source of Text10 I put:
=[INCOME1] + [INCOME2] . In the before update of Text16 I put this
procedure.

Private Sub Text16_BeforeUpdate(Cancel as Integer)
Me!TOTALINCOME = Me!Text10
End Sub

No Errorr messages were received, INCOMETOTAL was not updated

:

On Sat, 3 Dec 2005 15:15:02 -0800, "Bob B"

I tried what you sugested without success. I have 2 screen dumps of
what I
did that I would like to send you. I don't see anyway I can attach them
to
this apply. Can I have your e-mail address so I can pass them along to
you?

Private email support is provided for paying consulting customers.
Unpaid volunteer support on these newsgroups is free.

If you can, please describe what you did and the error message in
text. Screenshots will be less than helpful in any case.

John W. Vinson[MVP]
 
I created a sample data base for this discussion. The three fields in the
file are INCOME1, INCOME2, AND INCOMETOTAL. In the form view I created 2
text boxes; Text10 & Text16. In the data control source of Text10 I put:
=[INCOME1] + [INCOME2] . In the before update of Text16 I put this
procedure. Text10 does show the total of INCOME1 + INCOME2

Private Sub Text16_BeforeUpdate(Cancel as Integer)
Me!INCOMETOTAL = Me!Text10
End Sub



Douglas J Steele said:
So what's the exact code you're using now, and what event is it running on?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Bob B said:
Yes I did have that wrong, but when I changed it to ICOMETOTAL the name in
the data sheet it still did not update.

Douglas J. Steele said:
John had suggested putting the code in the form's BeforeUpdate event, not
the BeforeUpdate event associated with one of the controls.

As well, if what you've got below is an actual copy-and-paste of your code,
you're referring to the field as TOTALINCOME in code, whereas everywhere
else you're calling it INCOMETOTAL.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



I created a sample data base for this discussion. The three fields in the
file are INCOME1, INCOME2, AND INCOMETOTAL. In the form view I created 2
text boxes; Text10 & Text16. In the data control source of Text10 I put:
=[INCOME1] + [INCOME2] . In the before update of Text16 I put this
procedure.

Private Sub Text16_BeforeUpdate(Cancel as Integer)
Me!TOTALINCOME = Me!Text10
End Sub

No Errorr messages were received, INCOMETOTAL was not updated

:

On Sat, 3 Dec 2005 15:15:02 -0800, "Bob B"

I tried what you sugested without success. I have 2 screen dumps of
what I
did that I would like to send you. I don't see anyway I can attach them
to
this apply. Can I have your e-mail address so I can pass them along to
you?

Private email support is provided for paying consulting customers.
Unpaid volunteer support on these newsgroups is free.

If you can, please describe what you did and the error message in
text. Screenshots will be less than helpful in any case.

John W. Vinson[MVP]
 
You've still got it in the text box's BeforeUpdate event. Both John & I have
told you it needs to be in the form's BeforeUpdate event.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Bob B said:
I created a sample data base for this discussion. The three fields in the
file are INCOME1, INCOME2, AND INCOMETOTAL. In the form view I created 2
text boxes; Text10 & Text16. In the data control source of Text10 I put:
=[INCOME1] + [INCOME2] . In the before update of Text16 I put this
procedure. Text10 does show the total of INCOME1 + INCOME2

Private Sub Text16_BeforeUpdate(Cancel as Integer)
Me!INCOMETOTAL = Me!Text10
End Sub



Douglas J Steele said:
So what's the exact code you're using now, and what event is it running
on?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Bob B said:
Yes I did have that wrong, but when I changed it to ICOMETOTAL the name
in
the data sheet it still did not update.

:

John had suggested putting the code in the form's BeforeUpdate event, not
the BeforeUpdate event associated with one of the controls.

As well, if what you've got below is an actual copy-and-paste of your code,
you're referring to the field as TOTALINCOME in code, whereas
everywhere
else you're calling it INCOMETOTAL.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



I created a sample data base for this discussion. The three fields
in the
file are INCOME1, INCOME2, AND INCOMETOTAL. In the form view I created 2
text boxes; Text10 & Text16. In the data control source of Text10
I put:
=[INCOME1] + [INCOME2] . In the before update of Text16 I put
this
procedure.

Private Sub Text16_BeforeUpdate(Cancel as Integer)
Me!TOTALINCOME = Me!Text10
End Sub

No Errorr messages were received, INCOMETOTAL was not updated

:

On Sat, 3 Dec 2005 15:15:02 -0800, "Bob B"

I tried what you sugested without success. I have 2 screen dumps
of
what I
did that I would like to send you. I don't see anyway I can
attach them
to
this apply. Can I have your e-mail address so I can pass them
along to
you?

Private email support is provided for paying consulting customers.
Unpaid volunteer support on these newsgroups is free.

If you can, please describe what you did and the error message in
text. Screenshots will be less than helpful in any case.

John W. Vinson[MVP]
 
How do I get to the forms BeforeUpdte event?

Douglas J. Steele said:
You've still got it in the text box's BeforeUpdate event. Both John & I have
told you it needs to be in the form's BeforeUpdate event.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Bob B said:
I created a sample data base for this discussion. The three fields in the
file are INCOME1, INCOME2, AND INCOMETOTAL. In the form view I created 2
text boxes; Text10 & Text16. In the data control source of Text10 I put:
=[INCOME1] + [INCOME2] . In the before update of Text16 I put this
procedure. Text10 does show the total of INCOME1 + INCOME2

Private Sub Text16_BeforeUpdate(Cancel as Integer)
Me!INCOMETOTAL = Me!Text10
End Sub



Douglas J Steele said:
So what's the exact code you're using now, and what event is it running
on?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Yes I did have that wrong, but when I changed it to ICOMETOTAL the name
in
the data sheet it still did not update.

:

John had suggested putting the code in the form's BeforeUpdate event,
not
the BeforeUpdate event associated with one of the controls.

As well, if what you've got below is an actual copy-and-paste of your
code,
you're referring to the field as TOTALINCOME in code, whereas
everywhere
else you're calling it INCOMETOTAL.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



I created a sample data base for this discussion. The three fields
in
the
file are INCOME1, INCOME2, AND INCOMETOTAL. In the form view I
created 2
text boxes; Text10 & Text16. In the data control source of Text10
I
put:
=[INCOME1] + [INCOME2] . In the before update of Text16 I put
this
procedure.

Private Sub Text16_BeforeUpdate(Cancel as Integer)
Me!TOTALINCOME = Me!Text10
End Sub

No Errorr messages were received, INCOMETOTAL was not updated

:

On Sat, 3 Dec 2005 15:15:02 -0800, "Bob B"

I tried what you sugested without success. I have 2 screen dumps
of
what I
did that I would like to send you. I don't see anyway I can
attach
them
to
this apply. Can I have your e-mail address so I can pass them
along
to
you?

Private email support is provided for paying consulting customers.
Unpaid volunteer support on these newsgroups is free.

If you can, please describe what you did and the error message in
text. Screenshots will be less than helpful in any case.

John W. Vinson[MVP]
 
practica de grupo de noticias.

Bob B said:
I tried what you sugested without success. I have 2 screen dumps of what I
did that I would like to send you. I don't see anyway I can attach them to
this apply. Can I have your e-mail address so I can pass them along to you?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top