Update instruction help needed

  • Thread starter Thread starter Wolfgang Armbruster
  • Start date Start date
W

Wolfgang Armbruster

I'm trying to build a form which contains a calculated field. The
contents of this field should be saved into a table of the same database
by clicking on a button...

I've tried this piece of code

CurrentDb.Execute "Update Table1 " & _
"SET Field1 = " & Str(Me!FormField) & " " & _
"WHERE Index = "" & Me!Index & """

I do not get an error, but nothing is written to the table...

The index field is text and it's the primary index in the destination
table...

Any advice is much appreciated.
 
Generally there is no reason to store the results of a calculation in a
table. That's why Access does not support it directly. But if you absolutely
must store the results of a calculation in a table (for some very strange
reason) you can add the results field to the table and locate it on the
form. The form needs a text box to perform the calculation and an
AfterUpdate event to trigger a SetValue macro to store the calculated value.
 
Wolfgang said:
I'm trying to build a form which contains a calculated field. The
contents of this field should be saved into a table of the same
database by clicking on a button...

I've tried this piece of code

CurrentDb.Execute "Update Table1 " & _
"SET Field1 = " & Str(Me!FormField) & " " & _
"WHERE Index = "" & Me!Index & """

I do not get an error, but nothing is written to the table...

The index field is text and it's the primary index in the destination
table...

Any advice is much appreciated.


From what you say, it appears you are trying to save something you type
in a form's textbox concatenated with something already in the Table.
If so, that's not usually a good plan. Far better just to save the
typed entry on its own in a Field in the normal way. When you want the
concatenated information to show on a form or Report, do the
concatenation in the Query or in the Form or Report. By doing it in
this way, you will save yourself a great deal of difficulty further
down the line.

hth

Hugh
 
Hugh O'Neill schrieb / wrote... (Sat, 4 Oct 2003 20:41:53 +0000 (UTC))
From what you say, it appears you are trying to save something you type
in a form's textbox concatenated with something already in the Table.

Well, I do have a list (=table) of machines which is fix - no duplicates
allowed.

There is a form based on a different table but referencing to the same
basic "machine-table" where machine costs are simulated. This simulation
ends up in a figure in a calculated field.

The idea is to find a way to save this entry into a field of the "basic
table" by clicking a button.

This would mean that the user saves all simulated calculations in one
table. Only "wanted" results would be saved into the basic table and from
there on used for other purposes...

Does this clarify what I'm after? Is there a way to do it?

Thanks for helping me out.
 
Wolfgang said:
Hugh O'Neill schrieb / wrote... (Sat, 4 Oct 2003 20:41:53 +0000 (UTC))


Comments in-line:
Well, I do have a list (=table) of machines which is fix - no
duplicates allowed.

There is a form based on a different table but referencing to the
same basic "machine-table" where machine costs are simulated. This
simulation ends up in a figure in a calculated field.

The idea is to find a way to save this entry into a field of the
"basic table" by clicking a button.

Since you are able to calculate this result, why do you feel the need
to store it?
This would mean that the user saves all simulated calculations in one
table. Only "wanted" results would be saved into the basic table and
from there on used for other purposes...

This still does not give any reason to save the calculated results! If
you need to select some of the records only, then a Select Query will
do this using some criteria that you set.
Does this clarify what I'm after? Is there a way to do it?

Yes, this clarifies what your task is and shows that there is still no
need to save calculated results!
Thanks for helping me out.

hth

Hugh
 
Back
Top