Two options:
1) loop through each record and update (one at a time)
or
2) use an update query to update all of the city and state fields for a specific Zip. If you have 5 records with the same Zip, all 5 would be updated at the same time.
The pseudo code would be like
One record at a time:
Code:
'Open a records set to select the records
Single record: "SELECT Zip From TABLE1 WHERE Not IsNull(Zip ) and IsNull(City) and IsNull(State) Order By Zip"
If recordset returns records
'Start loop
'open a second recordset on Table2 to get the city and State
"SELECT City, State FROM TABLE2 WHERE Zip = '" & RS1("Zip") & "';"
If recordset returns records
rs.Edit
rs("City") = varCity ',- variable name
rs("City") = varState ',- variable name
rs.Update
Close second recordset (table 2)
Loop
'do cleanup stuff
Group records:
Code:
'Open a records set to select the records
Group records: "SELECT DISTINCT Zip From TABLE1 WHERE Not IsNull(Zip ) and IsNull(City) and IsNull(State) Order By Zip"
If recordset returns records
'Start loop
'open a second recordset on Table2 to get the city and State
"SELECT City, State FROM TABLE2 WHERE Zip = '" & RS1("Zip") & "';"
If recordset returns records
CurrentdB.Execute "UPDATE Table1 SET Table1.City = '" & varCity & "', Table1.State = '"& varState &"';"
Close second recordset (table 2)
Loop
'do cleanup stuff
This can be run from a button on the form.....