show hide label based on textbox (1 Viewer)

Siegfried

Registered User.
Local time
Today, 11:09
Joined
Sep 11, 2014
Messages
105
Dear experts,

Appreciate if you could help me with the following issue I'm stuck with.
I have a continuous form EmployeeDashboardF.
On the form I would like to display a label with a colored dot basis the content of the text box EmployeeStatus.
I have following 4 labels:
show lblblack if EmployeeStatus is no longer employed
show lblgreen if EmployeeStatus is active
show lblred if EmployeeStatus is absent
show lblorange if EmployeeStatus is joining or leaving

Entered following code per label/status but can't get it to work.
Below the code for lblgree having status active.

Code:
Private Sub Form_AfterUpdate()
  If Me!EmployeeStatus.Value = "active" Then
      Me!lblgreen.Visible = True
   Else
      Me!lblgreen.Visible = False
    
   End If
End Sub

Private Sub Form_AfterUpdate()
  If Me!EmployeeStatus.Value = "active" Then
      Me!lblgreen.Visible = True
   Else
      Me!lblgreen.Visible = False
   End If
End Sub

Thanks for your help.

Best regards,

Siegfried
 
Last edited by a moderator:

isladogs

MVP / VIP
Local time
Today, 10:09
Joined
Jan 14, 2017
Messages
18,186
Entered following code per label/status but can't get it to work.
That doesn't help us help you. What does happen when you apply your code?

In a continuous form you have multiple copies of the same controls. So in many cases the effect is that all the controls have the same outcome. All visible or all hidden
You might want to consider using conditional formatting on the EmployeeStatus textbox (or an unbound textbox) to set its colour according to the EmployeeStatus value

NOTE I added code tags (# button on toolbar) to improve readability. Please could you do the same in your other new thread
 

vba_php

Forum Troll
Local time
Today, 05:09
Joined
Oct 6, 2019
Messages
2,884
In a continuous form you have multiple copies of the same controls. So in many cases the effect is that all the controls have the same outcome. All visible or all hidden
colin,

why do you think he's using a cont. form? he says nothing about it here. in his other thread he's got 3 images attached and one shows that he is using a single form for that question.

sieg,

why doesn't ur code work? does it error out or just run without a result? and ur using "me!". replace "me!" with "me." and see if it works. also consider putting a button on the form that says something like "update records" for user to click, then behind it's click event, specify the visibility of the label.
 

isladogs

MVP / VIP
Local time
Today, 10:09
Joined
Jan 14, 2017
Messages
18,186
colin,
why do you think he's using a cont. form? he says nothing about it here. in his other thread he's got 3 images attached and one shows that he is using a single form for that question.

This is a bit of a clue...;)
I have a continuous form EmployeeDashboardF.
On the form I would like to display a label with a colored dot basis the content of the text box EmployeeStatus.
 

isladogs

MVP / VIP
Local time
Today, 10:09
Joined
Jan 14, 2017
Messages
18,186
As its your holiday we'll allow you the weekend off.
 

vba_php

Forum Troll
Local time
Today, 05:09
Joined
Oct 6, 2019
Messages
2,884
As its your holiday we'll allow you the weekend off.
I won't hijack this thread after this post, but I do want to tell u Colin that I do NOT get friday off work, even working at a federal building! you would think friday would be off for us, considering we get like 20 federal paid holidays off during the year, which includes Christmas Eve, and I believe that only started this year cuz that idiot in the white house declared it a holiday.
 

Siegfried

Registered User.
Local time
Today, 11:09
Joined
Sep 11, 2014
Messages
105
Colin, Adam,

Thanks for your help. Conditional formatting did the truck.

Best regards,
Siegfried
 

Siegfried

Registered User.
Local time
Today, 11:09
Joined
Sep 11, 2014
Messages
105
Solved, picture attached.:):):)
 

Attachments

  • condfromat.PNG
    condfromat.PNG
    6.9 KB · Views: 111

Users who are viewing this thread

Top Bottom