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

Report
Posts
58
Registration date
Thursday July 18, 2019
Status
Member
Last seen
October 17, 2020
-
Posts
2669
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
October 15, 2020
-
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
2669
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
October 15, 2020
446
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
2
Thank you

Glad we were able to help! Love us? Write us a review! Rate CCM

CCM 2942 users have said thank you to us this month

Posts
58
Registration date
Thursday July 18, 2019
Status
Member
Last seen
October 17, 2020

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
2669
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
October 15, 2020
446
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