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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare tables and then modify fields

Status
Not open for further replies.
Sep 21, 2001
28
US
I have a problem here. I need to compare two tables for related fields. If the fields match, then a field from table1 will copy to the correspondent field to table 2.
Table 1 is an update table with changes only to the Update field. The update field has an asterisk "*" in it indicating change to the record.

Example.
Table1: FName, LName, Area, Update[*]
Table2: FName, LName, Area, Update[ ]

Here is the psuedo code I need to convert to vb code.

Select first record w/ asterisk "*" in the Update field.

If T1.Fname = T2.FName
T1.LName = T2.Lname
T1.Area = T2.Area Then
Copy T1.Update to T2.Update
Copy "" to T1.Update

Next...

Thanks.
 

You really don't need to do this in VB code if you are dealing with tables. You should use queries. You'll need 2 queries.

1) Update table2 with data in table1.
2) Update (or delete) records in table1.

Query 1:
Update table2 As T2 Inner join table1 As T1
On T2.FName=T1.FName
And T2.LName=T1.LName
And T2.Area=T1.Area
Set T2.Update=T1.Update

Query 2:
Update table1 Set Update="" Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top