how to writing form value back to a field in a table ?.

G

Guest

I have a form called GCS with the following fields on it as textboxes which
pull values from an underlying table called GCS.

Cleaning Total
Tax Amount
Tax Rate


Additionally there is another textbox called Order Total which has the
following formula under the Control Source

=Nz([txtCleaningTotal])+Nz([txtTaxAmount])

This calculates the value of Order Total as desired but I can not figure out
how to write the value of Order Total back to the Order Total field in the
GCS table.

I've set-up in Event tab, After Update this code

UPDATE [GCS] SET GCS.OrderTotal = [Forms]![GCS]![txtOrderTotal] WHERE
(((GSC.CleaningOrderID)=[Forms]![GCS]![txtOrderTotal]));

***CleaningOrderID is primery key of GCS table

Thanks in advance for your help.
 
F

fredg

I have a form called GCS with the following fields on it as textboxes which
pull values from an underlying table called GCS.

Cleaning Total
Tax Amount
Tax Rate

Additionally there is another textbox called Order Total which has the
following formula under the Control Source

=Nz([txtCleaningTotal])+Nz([txtTaxAmount])

This calculates the value of Order Total as desired but I can not figure out
how to write the value of Order Total back to the Order Total field in the
GCS table.

I've set-up in Event tab, After Update this code

UPDATE [GCS] SET GCS.OrderTotal = [Forms]![GCS]![txtOrderTotal] WHERE
(((GSC.CleaningOrderID)=[Forms]![GCS]![txtOrderTotal]));

***CleaningOrderID is primery key of GCS table

Thanks in advance for your help.

You are using an Access database not an Excel spreadsheet.
Adjust your thinking accordingly.

There is no reason to save the calculated data in your table.
Delete the [OrderTotal] field from that table.

As long as you store the [txtCleaningTotal] and [txtTaxAmount] data,
whenever you need the result of the calculation, re-calculate it,
using the same expression you used above.
Storing calculated data wastes space and can easily result in wrong
data if one of the underlying fields has been changed.
 
J

JethroUK©

You can do away with calculating on the form & the need to store the result
& hence writing back to table by using a calculated field in a query
instead:

Order Total :=Nz([txtCleaningTotal])+Nz([txtTaxAmount])

base your form on the query & include the Order total on the form
 

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

Top