MikeKohler
Technical User
I have the following code, what I want to do is if one record has a certain value then the record in the second table will now contain that value. This is the code that I have been using.
Sub CombineFields()
Dim db As Database
Dim rst1 As Recordset 'PT001
Dim rst2 As Recordset 'tbl01
Dim tbl1 As TableDef 'PT001
Dim tbl2 As TableDef 'tbl01
Dim fld As Field
Set db = CurrentDb()
Set rst1 = db.OpenRecordset("PT001"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Set rst2 = db.OpenRecordset("tbl01"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
For Each fld In rst1.Fields
If "ROLL" = "dROLLNUMBER" Then
rst1.Edit
rst1![Contact] = rst2![CUSTNMBR1]
rst1.Update
End If
Next
rst1.Close
rst2.Close
End Sub
Thank you,
Michael Kohler
mkohler@telusplanet.net
Sub CombineFields()
Dim db As Database
Dim rst1 As Recordset 'PT001
Dim rst2 As Recordset 'tbl01
Dim tbl1 As TableDef 'PT001
Dim tbl2 As TableDef 'tbl01
Dim fld As Field
Set db = CurrentDb()
Set rst1 = db.OpenRecordset("PT001"
Set rst2 = db.OpenRecordset("tbl01"
For Each fld In rst1.Fields
If "ROLL" = "dROLLNUMBER" Then
rst1.Edit
rst1![Contact] = rst2![CUSTNMBR1]
rst1.Update
End If
Next
rst1.Close
rst2.Close
End Sub
Thank you,
Michael Kohler
mkohler@telusplanet.net