Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How update field value in a table using a form boud to another table

Posted on 2014-02-15
4
Medium Priority
?
3,033 Views
Last Modified: 2014-02-15
On a form bound to table 1 I have a number field.  When the value of the field on the form is changed I want the same field in table 2 to be changed to the same value.  They both have the same field name.

How can I do this in VBA code?

--Steve
0
Comment
Question by:SteveL13
[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
  • 2
4 Comments
 

Author Comment

by:SteveL13
ID: 39861366
Meant to mention... the value has to update the same key record and only that record.
0
 
LVL 52

Accepted Solution

by:
Gustav Brock earned 1000 total points
ID: 39861428
Use the AfterUpdate event:


Set rs = db.OpenRecordset("Select YourFieldName From OtherTable Where ID = " & Me!ID & "")
rs.Edit
    rs!Fields(0).Value = Me!txtNumberField.Value
rs.Update
rs.Close

/gustav
0
 
LVL 39

Assisted Solution

by:PatHartman
PatHartman earned 1000 total points
ID: 39861433
Sounds like you need to rethink your table design.  Having two tables to hold the same information is poor practice.  When you want to relate tables, store the primary key of the table you want to reference as a foreign key.  So for example, when you look at an order, you want to see all the customer information but if you save it with the order, you will have to change it in every record in the order table if it changes in the client table.  The way relational databases solve that problem is by storing a pointer to the data rather than the data itself.  Then you use a query to join the two tables so you can see all the data at once.
0
 

Author Comment

by:SteveL13
ID: 39861441
I am going to accept multiple solutions.  The first one worked and the second one is great advice.

Thanks to both of you.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
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 …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

618 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