A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Change color



 
 
Thread Tools Display Modes
  #1  
Old November 24th, 2007, 04:06 PM posted to microsoft.public.access.forms
Ivor Williams
external usenet poster
 
Posts: 18
Default 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  
Old November 24th, 2007, 05:51 PM posted to microsoft.public.access.forms
Arvin Meyer [MVP]
external usenet poster
 
Posts: 4,231
Default 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  
Old November 24th, 2007, 05:57 PM posted to microsoft.public.access.forms
Linq Adams via AccessMonster.com
external usenet poster
 
Posts: 1,474
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:06 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.