Updating Values in a Table with values in a Query

  • Thread starter Thread starter Ayo
  • Start date Start date
A

Ayo

I have a TABLE and a QUERY.
How do I update a column in the TABLE with values from a column in the QUERY?

Help Please!!!
 
Ayo said:
I have a TABLE and a QUERY.
How do I update a column in the TABLE with values from a column in the
QUERY?


What have you tried? You would normally use an update query for this,
joining the query to the table on their common key values and updating the
table's field from the field in the query. That can be problematic if the
query isn't updatable, though, in which case there are some workarounds that
could be attempted.
 
That is what I am having problems with.
I created a query from the table using:
Days: DateDiff("d",[Date Invoice Received In A/P],[Date Invoice Received In
Market]), as the value in the query that I want to update in the table.

My original intent was to have the value in a column in my table be the
difference between two other column i.e. DateDiff("d",[Column1],",[Column1]).
I don't know how to do that. I was told to use a query which I created with a
column that uses Days:DateDiff("d",[Column1],",[Column1]). Now I need to
update the table with the values in the "Days" column from the Query.
 
My original intent was to have the value in a column in my table be the
difference between two other column i.e. DateDiff("d",[Column1],",[Column1]).
I don't know how to do that. I was told to use a query which I created with a
column that uses Days:DateDiff("d",[Column1],",[Column1]). Now I need to
update the table with the values in the "Days" column from the Query.

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]
 
Ayo said:
That is what I am having problems with.
I created a query from the table using:
Days: DateDiff("d",[Date Invoice Received In A/P],[Date Invoice Received
In
Market]), as the value in the query that I want to update in the table.

My original intent was to have the value in a column in my table be the
difference between two other column i.e.
DateDiff("d",[Column1],",[Column1]).
I don't know how to do that. I was told to use a query which I created
with a
column that uses Days:DateDiff("d",[Column1],",[Column1]). Now I need to
update the table with the values in the "Days" column from the Query.


I agree with John Vinson -- except perhaps in a data warehouse, there's no
good reason to store the calculated value, since it can always be calculated
whenever you need it from the two date values you do store.
 

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