Solved

MS access and Update/Select

Posted on 2016-11-02
5
21 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
5 Comments
 
LVL 119

Assisted Solution

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

Accepted Solution

by:
PatHartman earned 250 total points
Comment Utility
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
Comment Utility
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 34

Assisted Solution

by:PatHartman
PatHartman earned 250 total points
Comment Utility
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
Comment Utility
Thanks!
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
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 …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now