Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / June 2007

Tip: Looking for answers? Try searching our database.

Cannot use update query to update records in another query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
WarEagle90 - 13 Jun 2007 22:38 GMT
I need to update a field in one table with data from another table.  I have
joined the two tables in a query, but when I try to update the field using an
update query or using VBA, I get an error saying that the query is not
updatable.  I have checked several other queries that join multiple tables
and none of them will allow me to update any of the fields.  Any thoughts?

Thanks in advance for your assistance,

Dan
Joseph Meehan - 14 Jun 2007 00:13 GMT
> I need to update a field in one table with data from another table.
> I have joined the two tables in a query, but when I try to update the
[quoted text clipped - 6 lines]
>
> Dan

   Chances are the update being requested in ambiguous.  That is the
update, due to the relationships is not clear to Access what record(s) need
to be updated.

Signature

Joseph Meehan

Dia 's Muire duit

John W. Vinson - 14 Jun 2007 02:26 GMT
>I need to update a field in one table with data from another table.  I have
>joined the two tables in a query, but when I try to update the field using an
[quoted text clipped - 5 lines]
>
>Dan

Please post the SQL view of the query. Also indicate which field or fields are
the Primary Key of each table, and whether a relationship has been defined
between the tables (and on which fields).

            John W. Vinson [MVP]
WarEagle90 - 14 Jun 2007 16:39 GMT
John,

Joseph is probably right but I don't know how to fix the ambiguity.  Below
is the SQL view of the query I am try to update. I have to join the tables on
3 fields in order to make sure the right data gets to the right place.  When
I run qryTest which combines all the data, the records are all joined
properly.  The tables have a relationship that identifies the 3 fields that
are needed to properly join the data.

FYI:  The purpose of all this is to create a budget.  I have one table with
all the accounts from our accounting system and for each account there are 12
periods (1 for each month).  I have another table with water consumption data
that I use for forcasting and calculating next year's revenue.  I need to get
the revenue information into the account table.

Thanks for all the help.

Dan

SELECT [Copy1 Of tblActualBudgetHistory].ACTNUMBR_1, [Copy1 Of
tblActualBudgetHistory].ACTNUMBR_2, [Copy1 Of
tblActualBudgetHistory].PERIODID, [Copy1 Of tblActualBudgetHistory].ACTDESCR,
[Copy1 Of tblActualBudgetHistory].RequestedBudget,
qryRevenueByMonthByRevenueType.SumOfRevenue
FROM [Copy1 Of tblActualBudgetHistory] RIGHT JOIN
qryRevenueByMonthByRevenueType ON ([Copy1 Of
tblActualBudgetHistory].ACTNUMBR_1 =
qryRevenueByMonthByRevenueType.ACTNUMBR_1) AND ([Copy1 Of
tblActualBudgetHistory].ACTNUMBR_2 =
qryRevenueByMonthByRevenueType.ACTNUMBR_2) AND ([Copy1 Of
tblActualBudgetHistory].PERIODID = qryRevenueByMonthByRevenueType.PERIODID);

> >I need to update a field in one table with data from another table.  I have
> >joined the two tables in a query, but when I try to update the field using an
[quoted text clipped - 11 lines]
>
>              John W. Vinson [MVP]
John W. Vinson - 14 Jun 2007 19:00 GMT
>SELECT [Copy1 Of tblActualBudgetHistory].ACTNUMBR_1, [Copy1 Of
>tblActualBudgetHistory].ACTNUMBR_2, [Copy1 Of
[quoted text clipped - 8 lines]
>qryRevenueByMonthByRevenueType.ACTNUMBR_2) AND ([Copy1 Of
>tblActualBudgetHistory].PERIODID = qryRevenueByMonthByRevenueType.PERIODID);

The SumOfRevenue is the big red flag here. It appears that
qryRevenueByMonthByRevenueType is a Totals query; and no Totals query - nor
any query based on a Totals query - will ever be updateable.

What field or fields are you trying to update?

            John W. Vinson [MVP]
WarEagle90 - 14 Jun 2007 20:02 GMT
John,

You are correct.  This a totals query.  I am trying to update the field
[RequestedBudget].  I have created a table with this same data and linked the
two tables directly and I still have the same problem.  I think I may have a
solution.  I am going to add a unique identifier to
qryRevenueByMonthByRevenueType that matches the Primary key in the table and
then create a table as I did before and then try to update the tables.  At
least this way I eliminate the ambiguous part of the problem.

Again, thanks for your help.

Dan

> >SELECT [Copy1 Of tblActualBudgetHistory].ACTNUMBR_1, [Copy1 Of
> >tblActualBudgetHistory].ACTNUMBR_2, [Copy1 Of
[quoted text clipped - 16 lines]
>
>              John W. Vinson [MVP]
John W. Vinson - 14 Jun 2007 22:19 GMT
>You are correct.  This a totals query.  I am trying to update the field
>[RequestedBudget].  I have created a table with this same data and linked the
[quoted text clipped - 3 lines]
>then create a table as I did before and then try to update the tables.  At
>least this way I eliminate the ambiguous part of the problem.

That's one way; another is to use the DSum() builtin function - rather than a
totals query - to calculate the sum.

Ideally, you should NOT be storing a sum or any other calculated value in any
table field anyway. Sometimes it's necessary but you should ONLY do so when
there's no other good way to do the job. Here's my blurb on the subject:

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]
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.