Solved

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

Posted on 2014-02-15
4
2,470 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
  • 2
4 Comments
 

Author Comment

by:SteveL13
Comment Utility
Meant to mention... the value has to update the same key record and only that record.
0
 
LVL 49

Accepted Solution

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

Assisted Solution

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
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…

744 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

18 Experts available now in Live!

Get 1:1 Help Now