air1access
Technical User
I working with the code below.
This works perfectly if I just have 1 primary key that is a number field.
Now I have 2 fields that are the primary key. One is a number, and one is a text field.
I need to be able to compare each record by the 2 fields...
How can I get this to do that...?
Do Until rstBase.EOF
If rstVarying.EOF = True Then
rstBase.MoveNext
ElseIf rstBase(PrimaryKeyField) > rstVarying(PrimaryKeyField) Then
rstVarying.MoveNext
ElseIf rstBase(PrimaryKeyField) < rstVarying(PrimaryKeyField) Then
rstBase.MoveNext
Else
For Each fld In rstBase.Fields
If Nz(rstBase(fld.Name)) <> Nz(rstVarying(fld.Name)) Then
db.Execute "INSERT INTO Event_Changes_1 (Event_ID, FieldName, OldText, NewText, Modified_Date, Carrier) " & _
"SELECT " & rstBase(PrimaryKeyField) & ", '" & fld.Properties("Caption") & "','" & Nz(rstBase(fld.Name), "<Null>") & "','" & Nz(rstVarying(fld.Name), "<Null>") & "', '" & rstVarying!Modified_Date & "', '" & rstVarying!Display_Name & "';"
FieldChanged = True
End If
Next fld
rstBase.MoveNext
rstVarying.MoveNext
FieldChanged = False
End If
Loop
This works perfectly if I just have 1 primary key that is a number field.
Now I have 2 fields that are the primary key. One is a number, and one is a text field.
I need to be able to compare each record by the 2 fields...
How can I get this to do that...?
Do Until rstBase.EOF
If rstVarying.EOF = True Then
rstBase.MoveNext
ElseIf rstBase(PrimaryKeyField) > rstVarying(PrimaryKeyField) Then
rstVarying.MoveNext
ElseIf rstBase(PrimaryKeyField) < rstVarying(PrimaryKeyField) Then
rstBase.MoveNext
Else
For Each fld In rstBase.Fields
If Nz(rstBase(fld.Name)) <> Nz(rstVarying(fld.Name)) Then
db.Execute "INSERT INTO Event_Changes_1 (Event_ID, FieldName, OldText, NewText, Modified_Date, Carrier) " & _
"SELECT " & rstBase(PrimaryKeyField) & ", '" & fld.Properties("Caption") & "','" & Nz(rstBase(fld.Name), "<Null>") & "','" & Nz(rstVarying(fld.Name), "<Null>") & "', '" & rstVarying!Modified_Date & "', '" & rstVarying!Display_Name & "';"
FieldChanged = True
End If
Next fld
rstBase.MoveNext
rstVarying.MoveNext
FieldChanged = False
End If
Loop