I'm trying to do something simple...to set the background color of a report textbox based on the value in that box. I've got a bound text box showing the value of a field MasterContactID. For this example that value is 2166. I want to compare that value to the value of a field in another table. I've tried this with a dlookup. I've tried it several different ways
That did nothing. So I tried creating an unbound text box and setting it's value with:
That also did nothing, even though both textboxes on my report displayed the value 2166.
But if I make it really simple and do:
That code changed the background color like I wanted.
If both my boxes are displaying the same value, why doesn't my comparison between them work and change the background color? The MasterContactID field format is AutoNumber Long Integer, and the overallSelected field in tblLeadershipChoices is set to Number Long Integer, so the data types are the same.
Code:
If MasterContactID = DLookup("[overallSelected]", "[tblLeadershipChoices]", "75") Then
MasterContactID.BackColor = 255
End If
Code:
overallSelectedCurrent.Value = DLookup("[overallSelected]", "[tblLeadershipChoices]", "75")
If MasterContactID = overallSelectedCurrent Then
MasterContactID.BackColor = 255
End If
But if I make it really simple and do:
Code:
overallSelectedCurrent.Value = DLookup("[overallSelected]", "[tblLeadershipChoices]", "75")
If overallSelectedCurrent = "2166" Then
MasterContactID.BackColor = 255
End If
If both my boxes are displaying the same value, why doesn't my comparison between them work and change the background color? The MasterContactID field format is AutoNumber Long Integer, and the overallSelected field in tblLeadershipChoices is set to Number Long Integer, so the data types are the same.