Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditionally change BackColor of a textbox on a REPORT?

Status
Not open for further replies.

marnold37341

Programmer
Mar 4, 2002
7
US
I want to make the textbox black if the value of the Control Source = 0. Following the Help example for BackColor, here's what I did:
Has Module for Report Properties = Yes
TextBox Name = txtSSRSMon
TextBox Control Source = SSRSMon

The VB Module reads as follows:

***********

Option Compare Database

Sub Form_Current()
Dim lngBlack, lngWhite, varSSRSMon As Long
If Not IsNull(Me!txtSSRSMon.Value) Then
varSSRSMon = Me!txtSSRSMon.Value
Else
Exit Sub
End If
Debug.Print varSSRSMon
lngBlack = RGB(0, 0, 0)
lngWhite = RGB(255, 255, 255)
If varSSRSMon = 0 Then
Me!txtSSRSMon.BackColor = lngBlack
' Me!txtSSRSMon.Value = Null
Else
Me!txtSSRSMon.BackColor = lngWhite
End If
End Sub

*****************

I even put the Debug.Print staement in to atempt verifying the module was executing. I get no results, the Immediate window has no data from the Debug.Print statement, and the value of the field (0) is still visible, rather than "blacked" out.

Any help????

Mickey Arnold
marnold37341@yahoo.com
 
Hi,

If you really are talking about a report try to put code in the DETAIL_FORMAT event.

if Me!txtSSRSMon = 0 or vartype("txtSSRSMon") = vbnull then
Me!txtSSRSMon.BackColor = vbBlack
Me!txtSSRSMon = null
else
Me!txtSSRSMon.BackColor = vbwhite
end if

Hope it helps!


Salvatore Grassagliata
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top