How can i blink data in textbox on userform based on condition [Solved/Closed]

Report
Posts
69
Registration date
Thursday July 18, 2019
Status
Member
Last seen
January 15, 2021
-
Posts
2717
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
April 1, 2021
-
hello
i got this code from the internet about blinking in textbox by command button but i would do this without command button it's directly when i open the useform for more:
i have sheet1 contains data begins from a2: d and userform contains 4 textbox when i search data in textbox1 it gives me the rest data in textbox2,3,4 the textbox4 it should blink back color by red directly based on condition (textbox4=date+10 days) the column d is date

Dim i As Long
If Me.TextBox1 = "" Then
Me.Label1.Caption = "Textbox Cannot be blank...."
Me.Label1.ForeColor = vbRed
For i = 1 To 10
TextBox1.BackColor = vbRed
Application.Wait (Now + TimeValue("0:00:1"))
TextBox1.BackColor = vbGreen
Application.Wait (Now + TimeValue("0:00:1"))
TextBox1.BackColor = vbWhite

Next i

End If

2 replies

Posts
2717
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
April 1, 2021
458
Hi Abdel,

You will need to add If Then and ScreenUpdating for it to work:
Application.ScreenUpdating = True
If Application.Wait(Now + TimeValue("0:00:1")) Then
    TextBox1.BackColor = vbRed
End If
If Application.Wait(Now + TimeValue("0:00:1")) Then
    TextBox1.BackColor = vbWhite
End If


Best regards,
Trowa
Posts
69
Registration date
Thursday July 18, 2019
Status
Member
Last seen
January 15, 2021

hi, Trowa i'm really sorry about replying is too late it seems i don't check notification so i do not receive any message in my email , thanks for the code works very well
Posts
2717
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
April 1, 2021
458
I'm glad it work well Abdel. I also don't receive emails for reply's, I just check my messages after signing in to CCM. The bold messages are the ones that got reply's.

Best regards,
Trowa

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!