Solved Vba backcolor (1 Viewer)

skdn71

New member
Local time
Today, 10:18
Joined
Jul 23, 2023
Messages
22
Hello,

Could you please help with VBA

If value on Text box, the Box1 backcolor must be Red ( see picture)
If value on combobox the Box2 backcolor must be Red ( see picture)

Thank you
 

Attachments

  • Data.accdb
    564 KB · Views: 55
  • Prnscr.jpg
    Prnscr.jpg
    43 KB · Views: 50

Gasman

Enthusiastic Amateur
Local time
Today, 09:18
Joined
Sep 21, 2011
Messages
14,448
No VBA needed, use Conditional formatting.
 

skdn71

New member
Local time
Today, 10:18
Joined
Jul 23, 2023
Messages
22
I try with conditional formating but not working, I get color on Textbox instead of Box1

Please help
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:18
Joined
Sep 21, 2011
Messages
14,448
You are using the wrong button. :(
Use the one next to the Undeline button.

1690107057372.png
 

skdn71

New member
Local time
Today, 10:18
Joined
Jul 23, 2023
Messages
22
I get the same result
 

Attachments

  • 2023-07-23 12_20_45-Window.jpg
    2023-07-23 12_20_45-Window.jpg
    12.7 KB · Views: 56

Gasman

Enthusiastic Amateur
Local time
Today, 09:18
Joined
Sep 21, 2011
Messages
14,448
The CF has to be in the control you are trying to use it on? :(

You are using it on the field you are testing? :( However are you testing for anything? You need to test if the large controls are empty or not.

Anyway it show it is working, just on the wrong control.
 

skdn71

New member
Local time
Today, 10:18
Joined
Jul 23, 2023
Messages
22
I Can't use conditional formating on Box1 please check the attachement i can do only on Textbox
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:18
Joined
Sep 21, 2011
Messages
14,448
Sorry, I did not realise you actuall had a box, I thought that was just your techincal name for the control. :)
As you mention, they do not have a CF option.

So code as you requested.

1690108937275.png

Code:
Private Sub Naam_AfterUpdate()
If Not Me.Naam & "" = "" Then
    Me.Box1.BackColor = vbRed
End If
End Sub

However you have the backstyle as Transparent, so will never see the colour until you change that. :(
 

Users who are viewing this thread

Top Bottom