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

Solved/Closed
abdelfatah_0230 Posts 73 Registration date Thursday 18 July 2019 Status Member Last seen 23 July 2022 - 28 Mar 2020 à 03:21
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 - 28 May 2020 à 11:26
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 responses

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