Comparison to set background color of textbox (1 Viewer)

gschimek

Registered User.
Local time
Yesterday, 23:02
Joined
Oct 2, 2006
Messages
102
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
Code:
 If MasterContactID = DLookup("[overallSelected]", "[tblLeadershipChoices]", "75") Then
MasterContactID.BackColor = 255
End If
That did nothing. So I tried creating an unbound text box and setting it's value with:
Code:
overallSelectedCurrent.Value = DLookup("[overallSelected]", "[tblLeadershipChoices]", "75")
If MasterContactID = overallSelectedCurrent Then
MasterContactID.BackColor = 255
End If
That also did nothing, even though both textboxes on my report displayed the value 2166.

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
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.
 

Users who are viewing this thread

Top Bottom