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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Activate a textbox backcolor from another textboxes value

Status
Not open for further replies.

luccas

Technical User
Dec 21, 2000
30
0
0
US
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

End Sub

Regards
Rod

 
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

End Sub
 
Try this:

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.

 
Thanks - Placing the code in the OnPrint event was the key.
 
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,

PS: You can do same thin on Foms
 
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.

Try it, :)

PS: You can do same thing on Forms
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top