If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Change color
I've a form on which there is a check box TaskComp and a text box TaskDate.
Using the following VBA code, when the check box is checked, the Date in the text box is set to the current date. This works fine. Private Sub TaskComp_AfterUpdate() If TaskComp.Value = -1 Then TaskDate.Value = Date Else TaskDate.Value = Null End Sub I want the background color of the text box to change from whit to red when the check box is echecked, so I added to the code: Private Sub TaskComp_AfterUpdate() If TaskComp.Value = -1 Then TaskDate.Value = Date Else TaskDate.Value = Null If TaskComp.Value = -1 Then TaskDate.BackColor = 255 Else TaskDate.BackColor = 16777215 End Sub The date is updated as expected, but the text box background color is changed in the text box for every record, not just the current one. Is there a "work around" I can use to get what I'm after? Ivor |
#2
|
|||
|
|||
Change color
If you are working in a continuous form or datasheet, the current record IS
the form. You can use an expression with conditional formatting to change a record. In the form's design view, choose Format Conditional Formatting, and follow the wizard. -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "Ivor Williams" wrote in message news:MZX1j.37305$PE.30607@pd7urf1no... I've a form on which there is a check box TaskComp and a text box TaskDate. Using the following VBA code, when the check box is checked, the Date in the text box is set to the current date. This works fine. Private Sub TaskComp_AfterUpdate() If TaskComp.Value = -1 Then TaskDate.Value = Date Else TaskDate.Value = Null End Sub I want the background color of the text box to change from whit to red when the check box is echecked, so I added to the code: Private Sub TaskComp_AfterUpdate() If TaskComp.Value = -1 Then TaskDate.Value = Date Else TaskDate.Value = Null If TaskComp.Value = -1 Then TaskDate.BackColor = 255 Else TaskDate.BackColor = 16777215 End Sub The date is updated as expected, but the text box background color is changed in the text box for every record, not just the current one. Is there a "work around" I can use to get what I'm after? Ivor |
#3
|
|||
|
|||
Change color
Your form is either in Continuous or Datasheet view, as evidenced by every
TaskDate box turning red. In these views you have to use Conditonal Formatting to accomplish this. In Design View, select the TaskDate box, goto Format - Condition Formatting then Unde Condition1 select "Expression Is" Type in [TaskComp] = -1 Now, using the background pallet, select your color for the background when the checkbox is selected. When the condition isn't True the color will revert to whatever the default is. -- There's ALWAYS more than one way to skin a cat! Answers/posts based on Access 2000/2003 Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/200711/1 |
Thread Tools | |
Display Modes | |
|
|