Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

updateing a field from a calculation on a form

Status
Not open for further replies.

etcrier

Programmer
Sep 20, 2006
60
US
i cannot find in the FAQ s
how you do an event for the following.

I have a form with calculated fields on it like tax, totals etc etc.
i want to write those solutions back to the underlying table in corresponding fields of the table.
it seems the only data i can get written from the form is when i enter manually to each table field on the form.


thanks
 
can you be more specific do you want the calculated text boxes data be entered in the table fields ?

I will try my best to help others so will others do!!!!!
IGPCS
Brooklyn, NY
 
Yes, you should be more specific.

If at all possible, nix the idea of placing calculated values in a table. This is a fundamentally flawed concept in database design. Your busines functions and logic should handle recalcing your data when you display it.

IMHO, if you absolutely have to (and there can be legit reasons), create the fields in a separate table, linked by your identifier, and bind the relevant controls on your form to them.

Gary
gwinn7
 
Heh, wait a minute
let me explain

this application is creating invoices in which the price is based upon several factors (check boxes on the form).
so I need to store the calulated price back into the invoice detail table field to view into the future.

when the price or factors that can change the price occur 2 years from now the customer can still see the details of this line of the invoice or total invoice.
there may be nothing in the database with regard to product,price etc that could be used to recreate the $$$.
they may not even have that brand in their inventory any more but need to reprint an invoice for some reason

you never want to recalculate an invoice or any document if it is ever accessed from an archive period unless underlying data will never change.
and its too complicated for customers to keep old stuff with gerational product #s when prices change.

is not there a simple event that I can code to copy the calculated amount that is displayed back into the table used to make the form to begin with. this seems like such a simple thing.

As for making another record a gwinn7 suggested - thats ok but at some point I have to write a caluclated field into a table.

i must tell you i really appreciate hte time and thought all of you guys give me and others. a BIG BIG thank you.

once i get over this access hump I hope that maybe i could give back by helping others with basic stuff.

thanks

david
OKIDOKI
 
OK people
here is how I solved my problem for those that are interested

I did an update query duplicating the form calculations for price. i added a button to call the query on the form.
in the query i tested for empty fields and only those got updated so old records would not get changed once a value was set into the price field.

works great because the operator does not have to hit the update button unless changes have been made to the prodcut file. so they can just hit update once or so a day and all records get changed properly. as a trigger for the update record match I defaulted a value of "NONE" in a description field so update only looks at those records and the NONE get replaced by valid data of an alpha description field that i also write.


thanks

i still wish i could just do an update event on the field itself.
 
Hi David

Just for your information, there are ways of adding the contents of a calulated field on a form to a table.

presuming your form is bound to the table you could have used

fieldname = me.CalculatedTextBoxName.value

You could have also taken a look at the "insert into" SQL method in accesses help files.

Ian Mayor (UK)
Program Error
Programming is 1% coding, 50% error checking and 49% sweat as your application bombs out in front of the client.
 

price is a table field on a subform and cprice is the actual calculated price only on the form.
is this the proper format exactly.
i am very new at VB code formatting

Private Sub
"order detail".price = me.cprice.value
End Sub

also where exactly do i put the code since the only code I have done is on an "event handler" of a field ot value on the form visable or not. which one would I put this line of code on?


thanks so very much for your interest. it really helps me

david
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top