How can i blink data in textbox on userform based on condition

Solved/Closed
abdelfatah_0230 Posts 73 Registration date Thursday July 18, 2019 Status Member Last seen July 23, 2022 - Updated on Mar 28, 2020 at 05:50 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - May 28, 2020 at 11:26 AM
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
Related:

2 responses

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 552
Apr 20, 2020 at 12:14 PM
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
abdelfatah_0230 Posts 73 Registration date Thursday July 18, 2019 Status Member Last seen July 23, 2022
May 27, 2020 at 10:21 AM
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
0
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 552
May 28, 2020 at 11:26 AM
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
0