Solved

MS access and Update/Select

Posted on 2016-11-02
5
83 Views
Last Modified: 2016-11-03
How can I do something like below in MS access, where I'm updating a record in the  equipment table based on a related record in th e same equipment table.  

update equipment set local_indicator_id = (select local_id from equipment where id = 8309)  
where equipment.id = 8265
0
Comment
Question by:HLRosenberger
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 250 total points
ID: 41871067
try
update equipment set local_indicator_id = (select local_id from equipment As E where E.id = 8309)  
 where equipment.id = 8265
0
 
LVL 37

Accepted Solution

by:
PatHartman earned 250 total points
ID: 41871114
Open the QBE.
Add the equipment table twice.  The second instance will be suffixed with "_1".  This is just an alias
Draw join lines between the two tables.
Add selection criteria if necessary.
Select the column you want to update.
Change the query type to Update.
In the Update To line, type the name of the column that contains the data you want in the format -
[tablename].[columnname]
0
 
LVL 30

Expert Comment

by:hnasr
ID: 41871164
Other approach: to avoid hard coding the query.

Create a table u(f, t) with entries from id to id

f          t
8265 8309
------  ------

UPDATE  equipment  inner join u on equipment .local_indicator_id=u.f
set equipment .local_indicator_id =u.t
0
 
LVL 37

Assisted Solution

by:PatHartman
PatHartman earned 250 total points
ID: 41871221
I don't think the OP actually wants to have literals in the query.  Parameters perhaps, but not literals.  However, if there is no field on which to join the two instances, then a cross reference table might be needed.
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 41872029
Thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Access Runtime Error '3070' 5 52
Query Dilema in Access 2010 3 40
SQL using aggregate function with HAVING / WHERE clause. 8 51
Ms Access 2010 Setup (Executable file) 4 68
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question