Conditional Formatting on tick boxes

JPW

Registered User.
Local time
Today, 13:34
Joined
Nov 4, 2007
Messages
51
I have a form with various fields, tab control etc on it. I also have many tick boxes on it, and many of them work great.

However, I have two tick boxes that I want to reduce to just one. For example the current database has:

[ ] Can be released?
[ ] Can not be released?

I see it as a great benefit to the users that use this to just have the one tick box:

[ ] Released?

However, I want the text on 'Released' to appear green when tick box is ticked, and then appear red and display the text 'No Release' when the tick box is not ticked.

What's the best way to achieve such function?

Thank you
 
A small example.
you can use Forecolor or backcolor. For the backcolor to be visible set backstyle to normal

enjoy!
 

Attachments

That code if (obviously adapted for my database) works perfectly to change the colour - thank you!

However, I would like it to display alternative text. What would be the VB code for that?

BoxTicked = 'Release' text to be displayed in labal
Box not ticked = 'No Release' text to be displayed in label

Where would it fit into the code below:

If Me.TickRelease = True Then
Me.LabelRelease.ForeColor = RGB(69, 139, 0)
Else
Me.LabelRelease.ForeColor = RGB(238, 0, 0)
End If
 
That code if (obviously adapted for my database) works perfectly to change the colour - thank you!

However, I would like it to display alternative text. What would be the VB code for that?

BoxTicked = 'Release' text to be displayed in labal
Box not ticked = 'No Release' text to be displayed in label

Where would it fit into the code below:

If Me.TickRelease = True Then
Me.LabelRelease.ForeColor = RGB(69, 139, 0)
Else
Me.LabelRelease.ForeColor = RGB(238, 0, 0)
End If

Try this:

If Me.TickRelease = True Then
Me.LabelRelease.ForeColor = RGB(69, 139, 0)
Me.LabelRelease.Caption = "Release"
Else
Me.LabelRelease.ForeColor = RGB(238, 0, 0)
Me.LabelRelease.Caption = "No Release"
End If

HTH,
Shane
 
Sorry another question of similar nature

I have another check box called 'Tick7Day' and a textbox called 'Text7Day'.

I want the check box, when ticked, to insert the current date into the check box. Not sure of the code, and now sure of whether to use VB or conditon formatting tool for this.
 
Sorry another question of similar nature

I have another check box called 'Tick7Day' and a textbox called 'Text7Day'.

I want the check box, when ticked, to insert the current date into the check box. Not sure of the code, and now sure of whether to use VB or conditon formatting tool for this.

Do you mean you want insert the current date into the textbox? By current date do you mean today's date? If so then something like this in the AfterUpdate event of the checkbox would work:

Code:
    If Me.Tick7Day Then
        Me.Text7Day = Date()
    Else
        Me.Text7Day = ""
    End If

HTH,
Shane
 

Users who are viewing this thread

Back
Top Bottom