writing values to a table (1 Viewer)

Housey

Registered User.
Local time
Today, 20:23
Joined
Nov 23, 2004
Messages
17
Hi,

I have a check box that gets ticked when 'work complete', it adds the parts/service totals and fills in the 'parts total', 'vat' and 'total' fields.

This works fine but I need it to write the values to the table as well rather than just displaying the values in the fields so reports can be produced etc.

Anyone know the easiest way to do this?

Thanks

Housey
 

FoFa

Registered User.
Local time
Today, 08:23
Joined
Jan 29, 2003
Messages
3,672
Use bound fields?
Use a query that pulls the values from the form and either updates or inserts the values required.
Use VBA to write the values to a table.
 

Housey

Registered User.
Local time
Today, 20:23
Joined
Nov 23, 2004
Messages
17
Thanks for the reply, does anyone have an example of how this would work. I understand roughly what you are saying but need help with the syntax...
 

FoFa

Registered User.
Local time
Today, 08:23
Joined
Jan 29, 2003
Messages
3,672
If the fields on the form you are filling are in the same table the form is based on, just bind those fields to the table.
If that does not apply, create an append query (to insert) into whatever table you need, have the query pull the values from your form.
INSERT INTO MyTable (Col1, Col2, Col3)
SELECT Forms!MyFormName!MyCol1 as Col1, Forms!MyFormName!MyCol2 as Col2, Forms!MyFormName!MyCol3 as Col3

basically
 

Radach

New member
Local time
Today, 09:23
Joined
Oct 10, 2005
Messages
7
I have a similar problem. I have text fields that perform calculations and would like to store the value in the table. I have a form based on a table and I have fields that are bound. In one of my text fieldcalcuation it has =[YWC]/[WordCount] for the control source. So how can I bind this field to the field in the table so the value will get stored in the table??
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 09:23
Joined
Feb 19, 2002
Messages
43,668
If the ControlSource is anything other than the name of a field in the form's RecordSource, the control is NOT bound. So your =[YWC]/[WordCount] is not a bound field. How would Access know where to save the value? This particular value should NOT be stored under any conditions. You should calculate the value in a query.

To store a calculated value in the table, use the following syntax:

Me.YourField = your calculation

The event to use depends on the calculation since you don't want to do the calculation until all values are present. The safest place to perform the calculation is the form's BeforeUpdate event.

Be VERY careful about what you store. It is almost always WRONG to store calculated values.
 

Users who are viewing this thread

Top Bottom