Change Field BackColours When A Tickbox Is True

B

Bateman28

Hi

I am trying to figure out how to change certain fields when a tickbox is
ticked to the value of True. My Tickbox is named WDAccessed.

I have tried the following;

Private Sub WDAccessed_Click()

If Me![WDAccessed] = True Then

Me![FullName.BackColour] = 255 Colour Red
Me![WorkDueDate.BackColour] = 255 Colour Red

Else

Me![FullName.BackColour] = -2147483643 Normal BackColour
Me![WorkDueDate.BackColour] = 2147483643 Normal BaclColour

End If
End Sub

Any help would be great.....Cheers

By: Bateman28 In: microsoft.public.access.formscoding

Me.ControlName.BackColor = xxxx

I don't believe that the Brit spelling of "colour" works, but I could be
fulla crap (wouldn't be the first time - heh)


Hi Dennis

I have tried the code you suggested and it worked, the only problem is that
when my tick box is ticked "True" the whole column within the specified field
name changes colour, is there a way in which to make it so that only the
record that the tick box is to the value of true changes colour and the
fields that are not ticked stay there original colour???

Any help would be great!

Cheers
 
D

Daniel Pineault

Whatch your bracketing and your spelling (Color not Colour). Try:

If Me.[WDAccessed] = True Then
Me.[FullName].BackColor = 255 'Colour Red
Me.[WorkDueDate].BackColor = 255 'Colour Red
Else
Me.[FullName].BackColor = -2147483643 'Normal BackColour
Me.[WorkDueDate].BackColor = -2147483643 'Normal BaclColour
End If

--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 
D

Daryl S

Bateman28 -

The struggle with continuous forms can be overcome to a degree.

Here is a trick that will work for the font color (forecolor), but not the
back color... You would do this for each field you want to display with a
different color, font, size, bold, etc.

For this example, I will assume FullName is the field you want to show in
different colors.

In your form, add two unbound textboxes, one called txtFullNameEnhanced and
one txtFullNameNormal.

Format txtFullNameNormal with the normal choices for color, font, etc. Set
the control to be this:
=IF(WDAccessed_Click,NULL,Me.FullName)

Format txtFullNameEnhanced with the font changes you want (Red, Bold, etc.).
Set the Back Style to Transparent. Set the control to be this:
=IF(WDAccessed_Click,Me.FullName,NULL)

Now, put the txtFullNameEnhanced on top of txtFullNameNormal. (If it goes
behind, use the Format BringToFront to put it on top.

Now set the visible property of the FullName control to No.

Move the controls and adjust the labels as needed. Test it out. The top
control will have nothing in it when the checkbox is not checked, and the
transparent background will let you see the normal control behind it. When
the checkbox is checked, the top control will have the formatting and value
you want, while the 'normal' control will not.

Check it out!
 
B

Bateman28

Hi Daryl

Cheers for response, i've tried this code and it just leaves a blank box on
the field FullName. I'm not sure if this is becasue the txtbox normal is on
top of txtbox enhanced, i placed the txtbox normal on top of the FullName
field as advised with the FullName field being set to not visable. I then
placed the txtbox txtbox enhanced on top of the Txtbox Normal. You mentioned
bring the Enhanced txtbox to the top incase it fell behind the normal txtbox.
From the format tab in the properties where is the function BringToFront, as
this could be the issue of seeing a blank field.

Oh when i tick the WDAccessed box the field is also blank!

Cheers


Daryl S said:
Bateman28 -

The struggle with continuous forms can be overcome to a degree.

Here is a trick that will work for the font color (forecolor), but not the
back color... You would do this for each field you want to display with a
different color, font, size, bold, etc.

For this example, I will assume FullName is the field you want to show in
different colors.

In your form, add two unbound textboxes, one called txtFullNameEnhanced and
one txtFullNameNormal.

Format txtFullNameNormal with the normal choices for color, font, etc. Set
the control to be this:
=IF(WDAccessed_Click,NULL,Me.FullName)

Format txtFullNameEnhanced with the font changes you want (Red, Bold, etc.).
Set the Back Style to Transparent. Set the control to be this:
=IF(WDAccessed_Click,Me.FullName,NULL)

Now, put the txtFullNameEnhanced on top of txtFullNameNormal. (If it goes
behind, use the Format BringToFront to put it on top.

Now set the visible property of the FullName control to No.

Move the controls and adjust the labels as needed. Test it out. The top
control will have nothing in it when the checkbox is not checked, and the
transparent background will let you see the normal control behind it. When
the checkbox is checked, the top control will have the formatting and value
you want, while the 'normal' control will not.

Check it out!

--
Daryl S


Bateman28 said:
Hi

I am trying to figure out how to change certain fields when a tickbox is
ticked to the value of True. My Tickbox is named WDAccessed.

I have tried the following;

Private Sub WDAccessed_Click()

If Me![WDAccessed] = True Then

Me![FullName.BackColour] = 255 Colour Red
Me![WorkDueDate.BackColour] = 255 Colour Red

Else

Me![FullName.BackColour] = -2147483643 Normal BackColour
Me![WorkDueDate.BackColour] = 2147483643 Normal BaclColour

End If
End Sub

Any help would be great.....Cheers

By: Bateman28 In: microsoft.public.access.formscoding

Me.ControlName.BackColor = xxxx

I don't believe that the Brit spelling of "colour" works, but I could be
fulla crap (wouldn't be the first time - heh)


Hi Dennis

I have tried the code you suggested and it worked, the only problem is that
when my tick box is ticked "True" the whole column within the specified field
name changes colour, is there a way in which to make it so that only the
record that the tick box is to the value of true changes colour and the
fields that are not ticked stay there original colour???

Any help would be great!

Cheers
 
B

Bateman28

Please ignore the part where i say as i have figured where the bring to front
option is, any help would still be greatly appreciated

"From the format tab in the properties where is the function BringToFront, as
this could be the issue of seeing a blank field"

Bateman28 said:
Hi Daryl

Cheers for response, i've tried this code and it just leaves a blank box on
the field FullName. I'm not sure if this is becasue the txtbox normal is on
top of txtbox enhanced, i placed the txtbox normal on top of the FullName
field as advised with the FullName field being set to not visable. I then
placed the txtbox txtbox enhanced on top of the Txtbox Normal. You mentioned
bring the Enhanced txtbox to the top incase it fell behind the normal txtbox.
From the format tab in the properties where is the function BringToFront, as
this could be the issue of seeing a blank field.

Oh when i tick the WDAccessed box the field is also blank!

Cheers


Daryl S said:
Bateman28 -

The struggle with continuous forms can be overcome to a degree.

Here is a trick that will work for the font color (forecolor), but not the
back color... You would do this for each field you want to display with a
different color, font, size, bold, etc.

For this example, I will assume FullName is the field you want to show in
different colors.

In your form, add two unbound textboxes, one called txtFullNameEnhanced and
one txtFullNameNormal.

Format txtFullNameNormal with the normal choices for color, font, etc. Set
the control to be this:
=IF(WDAccessed_Click,NULL,Me.FullName)

Format txtFullNameEnhanced with the font changes you want (Red, Bold, etc.).
Set the Back Style to Transparent. Set the control to be this:
=IF(WDAccessed_Click,Me.FullName,NULL)

Now, put the txtFullNameEnhanced on top of txtFullNameNormal. (If it goes
behind, use the Format BringToFront to put it on top.

Now set the visible property of the FullName control to No.

Move the controls and adjust the labels as needed. Test it out. The top
control will have nothing in it when the checkbox is not checked, and the
transparent background will let you see the normal control behind it. When
the checkbox is checked, the top control will have the formatting and value
you want, while the 'normal' control will not.

Check it out!

--
Daryl S


Bateman28 said:
Hi

I am trying to figure out how to change certain fields when a tickbox is
ticked to the value of True. My Tickbox is named WDAccessed.

I have tried the following;

Private Sub WDAccessed_Click()

If Me![WDAccessed] = True Then

Me![FullName.BackColour] = 255 Colour Red
Me![WorkDueDate.BackColour] = 255 Colour Red

Else

Me![FullName.BackColour] = -2147483643 Normal BackColour
Me![WorkDueDate.BackColour] = 2147483643 Normal BaclColour

End If
End Sub

Any help would be great.....Cheers

By: Bateman28 In: microsoft.public.access.formscoding

Me.ControlName.BackColor = xxxx

I don't believe that the Brit spelling of "colour" works, but I could be
fulla crap (wouldn't be the first time - heh)


Hi Dennis

I have tried the code you suggested and it worked, the only problem is that
when my tick box is ticked "True" the whole column within the specified field
name changes colour, is there a way in which to make it so that only the
record that the tick box is to the value of true changes colour and the
fields that are not ticked stay there original colour???

Any help would be great!

Cheers
 
D

Daryl S

Bateman28 -

You may have an easier time debugging if you start with the three fields not
on top of each other. The regular field will always show the data in normal
view. Then only one of the other two (normal or enhanced) should have a
value in it at any time. The txtbox enhanced should always have the enhanced
features (font color, etc.). As you click the checkbox on and off, the
regular field won't change, but the value should switch between the
'enhanced' and 'normal' text boxes.

If nothing is happening when you turn the checkbox on and off, then debug
the code on the OnClick event of that checkbox. Let us know what you see so
we can help more...

--
Daryl S


Bateman28 said:
Please ignore the part where i say as i have figured where the bring to front
option is, any help would still be greatly appreciated

"From the format tab in the properties where is the function BringToFront, as
this could be the issue of seeing a blank field"

Bateman28 said:
Hi Daryl

Cheers for response, i've tried this code and it just leaves a blank box on
the field FullName. I'm not sure if this is becasue the txtbox normal is on
top of txtbox enhanced, i placed the txtbox normal on top of the FullName
field as advised with the FullName field being set to not visable. I then
placed the txtbox txtbox enhanced on top of the Txtbox Normal. You mentioned
bring the Enhanced txtbox to the top incase it fell behind the normal txtbox.
From the format tab in the properties where is the function BringToFront, as
this could be the issue of seeing a blank field.

Oh when i tick the WDAccessed box the field is also blank!

Cheers


Daryl S said:
Bateman28 -

The struggle with continuous forms can be overcome to a degree.

Here is a trick that will work for the font color (forecolor), but not the
back color... You would do this for each field you want to display with a
different color, font, size, bold, etc.

For this example, I will assume FullName is the field you want to show in
different colors.

In your form, add two unbound textboxes, one called txtFullNameEnhanced and
one txtFullNameNormal.

Format txtFullNameNormal with the normal choices for color, font, etc. Set
the control to be this:
=IF(WDAccessed_Click,NULL,Me.FullName)

Format txtFullNameEnhanced with the font changes you want (Red, Bold, etc.).
Set the Back Style to Transparent. Set the control to be this:
=IF(WDAccessed_Click,Me.FullName,NULL)

Now, put the txtFullNameEnhanced on top of txtFullNameNormal. (If it goes
behind, use the Format BringToFront to put it on top.

Now set the visible property of the FullName control to No.

Move the controls and adjust the labels as needed. Test it out. The top
control will have nothing in it when the checkbox is not checked, and the
transparent background will let you see the normal control behind it. When
the checkbox is checked, the top control will have the formatting and value
you want, while the 'normal' control will not.

Check it out!

--
Daryl S


:

Hi

I am trying to figure out how to change certain fields when a tickbox is
ticked to the value of True. My Tickbox is named WDAccessed.

I have tried the following;

Private Sub WDAccessed_Click()

If Me![WDAccessed] = True Then

Me![FullName.BackColour] = 255 Colour Red
Me![WorkDueDate.BackColour] = 255 Colour Red

Else

Me![FullName.BackColour] = -2147483643 Normal BackColour
Me![WorkDueDate.BackColour] = 2147483643 Normal BaclColour

End If
End Sub

Any help would be great.....Cheers

By: Bateman28 In: microsoft.public.access.formscoding

Me.ControlName.BackColor = xxxx

I don't believe that the Brit spelling of "colour" works, but I could be
fulla crap (wouldn't be the first time - heh)


Hi Dennis

I have tried the code you suggested and it worked, the only problem is that
when my tick box is ticked "True" the whole column within the specified field
name changes colour, is there a way in which to make it so that only the
record that the tick box is to the value of true changes colour and the
fields that are not ticked stay there original colour???

Any help would be great!

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top