Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MS access and Update/Select

Posted on 2016-11-02
5
Medium Priority
?
157 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 1000 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 39

Accepted Solution

by:
PatHartman earned 1000 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 31

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 39

Assisted Solution

by:PatHartman
PatHartman earned 1000 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

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…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

704 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