Okay, there's a way to do it. You might find it more trouble than it's worth, but here's what I did:
1) Made 2 tables: tblMyTable1 and tblMyTable2. Each has 4 fields: RecID (autonumber), MyField1, MyField2, MyField3 (all text fields)
2) Populated the tables with some sample data, in this case, names of colors (Red, Orange, Yellow, whatever) such that some corresponding fields in the tables hold matching data.
3) Built a query incorporating only the 6 relevant fields from the two tables. Named the fields (this is important!) A1, A2, A3, B1, B2, B3 - i.e. A1: tblMyTable1.MyField1; A2: tblMyTable1.MyField2, etc.
4) Built a continuous form. I believe the order in which you place the fields on the form is significant! As that becomes, I think, the ordinal number which determines the order in which conditional formatting is processed (I tried tab order, didn't work). Named the controls txtA1, txtA2, etc. and bound them to A1, A2, etc.
5) Specified conditional formatting for each field. Expression is (without the quote marks) "MyCondFormat([Form])" - and simply changed the background color for when the condition is met.
6) Created a public variable in a module:
Code:
Public fldIndex As Integer
7) Created the following function in a module:
Code:
Public Function MyCondFormat(FormObj As Form) As Boolean
If fldIndex = 0 Then
fldIndex = 1
End If
If FormObj("txtA" & fldIndex) = FormObj("txtB" & fldIndex) Then
MyCondFormat = True
Else
MyCondFormat = False
End If
fldIndex = Choose(fldIndex, 2, 3, 1)
End Function
8) In the form's Close event, put
(if this is the only form that would ever use the conditional formatting, could probably declare your variable and create the function in the form's module)
Okay, some major caveats here: this assumes ALL fields on the form are evaluated for conditional formatting - there may be a way to parse the field's ordinal number and compare it to the field's name, but I didn't want to go there... Also assumes the fields will be processed from left to right, top to bottom, i.e. Record1:Field1, Record1:Field2, etc. IOW, the code assumes the first field to be evaluated is named txtA1 and compares its value to that of txtB1; then it increments the fldIndex value, and goes to txtA2/txtB2, and so forth. This example includes 3 pairs of fields, the Choose statement needs to be altered if there are more/fewer.
This is kind of a kludge, but it works
within the parameters I specified. Give it go and see if it works for you...
Ken S.