I want to activate a textboxes color when the value of another text box = 0. Example: I have a parts list when the value of [parts ordered]-[Parts recieved] = 0. I want a textbox that I have placed over the that record to hilite a color.
Example: Suppose you have three fields: txtPtsReceived, txtPtsOrdered and txtPtsToFollow where the ControlSource of txtPtsToFollow is set to:
= [txtPtsOrdered] - [txtPtsReceived]
In the AfterUpdate event of txtPtsReceived insert the code below. When you enter the parts received the background colour of txtPtsToFollow will go red if the received orer is short, stay white if all parts were received and go light blue if excess parts were received.
Private Sub txtPtsReceived_AfterUpdate()
If txtPtsToFollow > 0 Then
txtPtsToFollow.BackColor = 255
Elseif txtPtsToFollow = 0 then
txtPtsToFollow.BackColor = 16777215
Else
txtPtsToFollow.Backcolor = 16776960
End If
I am using this code in a report and it goes to back color 255 regardless of the value of the value of the record PartsShort.
PartsShort=txtPtsToFollow
Text73= an unbound text box to display the back color.
Private Sub Report_Activate()
If PartsShort > 0 Then
Text73.BackColor = 16776960
ElseIf PartsShort = 0 Then
Text73.BackColor = 255
Else
Text73.BackColor = 900
End If
Listing the Record ID field from a series of records I used this code and the result was that the background colour of the field changed from black or very dark colour to light blue according to the code.
Notice I placed the code in the OnPrint event of the forms detail section.
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If RecID > 6 And RecID < 12 Then
Me.RecID.BackColor = 16776960
Else
Me.RecID.BackColor = 900
End If
End Sub
Also remember to set the fields BackStyle to Normal as it defaults to Transparent when the report layout is generated.
Hi luccas,
***Extra Information***
In Access 2000, you can use Condetional Formating on Format Menu to set up a maximum of three condetions for a specific field (text or numeric.On doing this, you can set Back Col,For Col and Font.
Try it,
Hi luccas,
***Extra Information***
In Access 2000, you can use Condetional Formating on Format Menu to set up a maximum of three condetions for a specific field (text or numeric).By doing this, you can set Back Col,For Col and Font.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.