JohnM
Well-known member
I have two tables, A and B. The first one (A) I need to read one record at a time against the other table (B). I want to read the entire B Table, if I have to, until I get a match for each record from Table A.
My question is once I read thru Table B, and now I want to take the second record from Table A and start all over again from the beginning of Table B. Do I have to reset Table B somehow in order for it to start at the beginning again?
It looks like this:
Dim dr As DataRow
Dim dr1 As DataRow
For Each dr1 In Cars1.Tables("Cars").Rows
a1 = dr1.Item(0) 'Rid #
a2 = dr1.Item(1) ' Year of Car
cnt = 0
For Each dr In HistoryRepairs1.Tables("HistoryRepairs").Rows
all = all + 1
a9 = dr.Item(0) 'Id #
a0 = dr.Item(1) ' Year of History
If a1 = a9 And a2 = a0 Then
MessageBox.Show("Match for " & a1 & " " & a2, "Has a history record" & a9 & " " & a0)
cnt = cnt + 1
Exit For
Else : End If
MessageBox.Show("Records read so far " & all, "History records")
Next
HistoryRepairs1.Tables("HistoryRepairs").Reset()
If cnt = 0 Then MessageBox.Show("no match for " & a1 & a2, "Needs a history record")
Next
Thank you for your time.
John M
My question is once I read thru Table B, and now I want to take the second record from Table A and start all over again from the beginning of Table B. Do I have to reset Table B somehow in order for it to start at the beginning again?
It looks like this:
Dim dr As DataRow
Dim dr1 As DataRow
For Each dr1 In Cars1.Tables("Cars").Rows
a1 = dr1.Item(0) 'Rid #
a2 = dr1.Item(1) ' Year of Car
cnt = 0
For Each dr In HistoryRepairs1.Tables("HistoryRepairs").Rows
all = all + 1
a9 = dr.Item(0) 'Id #
a0 = dr.Item(1) ' Year of History
If a1 = a9 And a2 = a0 Then
MessageBox.Show("Match for " & a1 & " " & a2, "Has a history record" & a9 & " " & a0)
cnt = cnt + 1
Exit For
Else : End If
MessageBox.Show("Records read so far " & all, "History records")
Next
HistoryRepairs1.Tables("HistoryRepairs").Reset()
If cnt = 0 Then MessageBox.Show("no match for " & a1 & a2, "Needs a history record")
Next
Thank you for your time.
John M