473,396 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to update a field in one table from another (a backup)?

sueb
379 256MB
I'm not sure how this happened, but the current version of a table in my database has lost all the values in one field. The previous backup has the correct values.

How do I copy the correct values into the current table? I know I'd use an update query, but I've only written one, and I really don't want to screw up the table any more than it already is, so maybe someone could tell me exactly how to write it.

The field in question is called [OR Time In Room], and it's in a table named "DataTable". (Don't blame me--I inherited this!)

Thanks!
Feb 16 '11 #1

✓ answered by NeoPa

I believe it would be [DataTable copy (2)].[OR Time In Room], but I normally work in SQL when working on something not in front of me. If you'd like to post the SQL then I can tell you the change more reliably (Not that I don't expect this to work - Just in case it doesn't). To see the SQL of the query simply select View SQL from the View menu. What is there is simple text and can be copied and pasted normally. Don't forget to use the CODE tags if posting code in here though ;-)

PS. To link tables in a database (so that you refer to the new linked table in your references, but the actual table is in a separate database, use File / Get External Data / Link Tables... This leaves you with a Linked Table in your database. For your use, copying the table in is a fine alternative approach. remember to delete the table when you're finished with it though, and to Compact/Repair your database after that. Otherwise it will not recover the internal space used for that data - even if the table is deleted.

4 1907
pod
298 100+
they are a few quick queryless ways I can think of doing this, since I have done the same thing a few time.

...presuming you have the same number of records in both the backup table and the live one:
  • and if only the one column's values differs between the backup and the live, why not replace the entire table with a copy of the backup.
  • else you could simply select the entire column in the backup table, copy, then select the same column in the live table then paste.
Feb 17 '11 #2
NeoPa
32,556 Expert Mod 16PB
  1. Create a (temporary) linked table from your main (current) database to the table in your backup database. We'll call this [DataTableBup] for now.
  2. Build a query, based on the main table ([DataTable]), within your main database and :
    1. Make it an Update query.
    2. Add the backup table ([DataTableBup]) to the query and connect the two tables with an INNER JOIN (Type 1 link) on the PK (Primary Unique Index).
    3. Set the value of the required field in the main table to that of the field in the backup table.
  3. Run the query.
Feb 17 '11 #3
sueb
379 256MB
Thanks, NeoPa! I got as far as step 2.2, but I don't know the syntax to address the field in the backup table.

My query contains the field Number (this is like a case number and is unique) from both tables, and the "OR Time In Room" fields from both tables. Because I didn't know how to make a link between tables in different projects, I copied the backup table into my live project, so the tables are named "DataTable" and "DataTable copy (2)".

What do I type into the Update To cell?
Feb 17 '11 #4
NeoPa
32,556 Expert Mod 16PB
I believe it would be [DataTable copy (2)].[OR Time In Room], but I normally work in SQL when working on something not in front of me. If you'd like to post the SQL then I can tell you the change more reliably (Not that I don't expect this to work - Just in case it doesn't). To see the SQL of the query simply select View SQL from the View menu. What is there is simple text and can be copied and pasted normally. Don't forget to use the CODE tags if posting code in here though ;-)

PS. To link tables in a database (so that you refer to the new linked table in your references, but the actual table is in a separate database, use File / Get External Data / Link Tables... This leaves you with a Linked Table in your database. For your use, copying the table in is a fine alternative approach. remember to delete the table when you're finished with it though, and to Compact/Repair your database after that. Otherwise it will not recover the internal space used for that data - even if the table is deleted.
Feb 18 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Caroline | last post by:
I need to update a table by copying a column from another table (having the same structure, but on another database), from the record having the same primary key. 1 - What is the correct...
1
by: John Baker | last post by:
HI: I have a drop down box on a form, which I am linking to a query on my client table, producing two fields client and clientID (the record ID). On a click on the appropriate record, I...
1
by: Tony Johnson | last post by:
I want to update a particular field in a form for only a certain set of records. The certain set of records is named Financed. I need to update those Financed records with a financed number that...
0
by: EKL | last post by:
Hi, I'm making a sort of Customer and Orders database in MS Access 2003. My problem is that I wish to update the table "tblTransaction" based on changes made in the table "tblOrderDetails"....
1
by: Sharon | last post by:
Hello All, Is it possible to update Sql Table through DataGrid. I have a DataGrid which is being populated through a stored procedure, all i wanted to do is to update one field...
1
by: Seemaraj | last post by:
I have doubt in VB.Net on how to update the records in table. I m using MS Access database. I have a table named len_graph with 9 fields like...
4
by: mmanojkumar | last post by:
Sir, I have a recordset "ADODC_path.recordset" which takes input from two tables When the field values are put into the textboxes and then edited and updated back into the tables, using the...
1
by: vaiism | last post by:
I have attempted using both Updata and Append Queries to solve this problem, and I can't seem to get it to work. I have three forms that each have an ID#, and a subform with related scores to...
1
by: lunas | last post by:
hi i have to update a table based on a criteria with value selected from another table. i am writting a java progg for it . i just want to know can it be done with one statement. my purpose is ...
3
by: ghost1980 | last post by:
hi there, i am new to ms access and currently i am in need of help. here is my problem i need to help create a form that allow me to update 2 tables. example: PERSON1 (table 1) id name dob...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.