Turning Red?

Mike.Howard79

New Member
Joined
Feb 23, 2010
Messages
21
Hi All,

I need a date field on a form to turn red if, in another field the check box is ticked (ie Visually says completed)

For the check box field i am using a yes/no and for the date field i am using date/time.

I hope this makes sense

Cheers

Mike
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Mike

Do you only want this to happen when the checkbox is clicked?

Is the checkbox unbound or is it bound to a field in the datasource?

If it's unbound then this small piece of code should do what you want.
Code:
Option Compare Database
Option Explicit
 
Private Sub Check8_Click()
    Me.RealDate.BackColor = IIf(Check8.value, vbRed, vbWhite)
End Sub
If it is bound you could probably use the AfterUpdate event and/or the form's load event.

You could also use conditional formatting in later versions of Access.
 
Upvote 0
Only when the check box is ticked and yes it is bound to another field within the same table as the date field

Hope this helps
 
Upvote 0
Well, I've not had time to check the bound part but try the code I've already posted in the meantime.

I'll check out the bound thing and post back - my only real concern there was what would happen when the form opened.

A different event would probably needed, perhaps one or both of the ones I mentioned.

Do you know if you can use conditional formatting?

If you can you wouldn't need any code at all and it should work with bound/unbound controls.:)

PS Not 100% sure about that last part - only recently found you could use conditional formatting on forms in Access 2010. Not sure if it's a good thing or bad thing.
 
Upvote 0
You'll want to check if the checkbox is null (so use Nz(MyCheckbox,False)). You can use either the Click or AfterUpdate events. You will also want to use the form's OnCurrent event so when you scroll between records the field will be colored appropriately.

hth,

Rich
 
Upvote 0

Forum statistics

Threads
1,215,214
Messages
6,123,659
Members
449,114
Latest member
aides

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top