Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

populate field based on selected data in another table 3

Status
Not open for further replies.

troyster

Technical User
Jan 18, 2002
10
US
I need to populate a field in another table based on data matching a filter in my prime database, i.e. place an "X" in tbl "B", Field Q for "*XYZ*" in tbl "A", Field "Z". Is this a possibility? I appreciate any assistance in this matter.
 
The answer depends on the relationship between table A and Table B. Is the a relationship between the tables - such as an ID. If so you can use a query like the following.

Update tblB
Set FieldQ="X"
From TblB Inner JOIN TblA
On TblB.ID=TblA.ID
Where TblA.FieldZ="*XYZ*"

If this isn't what you need, please provide more info about the tables and how you expect to match them. Terry L. Broadbent
Programming and Computing Resources
 
Yes the databases have a relationship field, the query above looks very good... extremely helpful... however is this a line of code to be in a module or other... how do I include this in the database?
Thanks for your reply
 
You can run an update query several ways. How you do it depends on the application design.

1) Create and save the query definition. Open the query manually, from a VBA code or a macros.

2) Create the code in a VBA module and execute it using one of the methods available such as DoCmd.RunSQL or Execute.

3) Execute a RunSQL action in a macro. Terry L. Broadbent
Programming and Computing Resources
 
Thanks... this should do the trick. I'll let you know how it goes.
 
Terry,
If you see this please advise me on this as I have tried your code and have issues I believe that is with the syntax. Perhaps I am doing the wrong thing, however I am using Access 2002 and keep getting error messages. Here it is in a nutshell; tbl A is Instrument and tbl B is ITR_Instrument the common field is Instr_Tag(both) and field to have "X" is E-01 in tbl ITR_Instrument looking for "not null" in field Field Installed of tbl Instrument. I apologize in advance for the trouble, however this is greatly appreciated. Thanks much for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top