+ Reply to Thread
Results 1 to 4 of 4

Problems Making A Userform Textbox Continue To Flash More Than 3 Times

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    09-14-2012
    Location
    Tucson, Arizona, USA
    MS-Off Ver
    Office 2010
    Posts
    105

    Problems Making A Userform Textbox Continue To Flash More Than 3 Times

    I've run into a tad bit of a problem, I'm trying to make a userform textbox flash continuously if there is an error in it. What I keep ending up with is it flashing to green, then red, finally back to green (3 flashes total) and stays green until the error is corrected. I get the why, but I'm trying to make it go for a lot longer than those 3 seconds (or whatever I set the timer to). I've placed the code I've managed to put together so far below. As always, all help is appreciated.

    BTW, I have tried using data validation, but that only appears to work if the userform is not used and the userform must be used in this instance.

    Private Sub cboTime_AfterUpdate()
    
        If cboTime.Value = txtLTime.Value Then
          cboTime.SetFocus
            cboTime.BackColor = RGB(0, 255, 0)
            Application.Wait Now + TimeValue("00:00:01")
            cboTime.BackColor = RGB(255, 0, 0)
            Application.Wait Now + TimeValue("00:00:01")
            cboTime.BackColor = RGB(0, 255, 0)
            Application.Wait Now + TimeValue("00:00:01")
          ElseIf cboTime.Value <> txtLTime.Value Then cboTime.BackColor = RGB(255, 255, 255)
        End If
            
    End Sub

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Problems Making A Userform Textbox Continue To Flash More Than 3 Times

    If I could suggest a more common approach would be to display a helpful message and then don't allow the user to exit cboTime as long as it equals txtLTime. This would mimic how Data Validation works on a worksheet.

    Private Sub cboTime_Exit(ByVal Cancel As MSForms.ReturnBoolean)
        If cboTime.Value = txtLTime.Value Then
            MsgBox "cboTime = txtTime" & vbLf & "Please make a different selection.", _
                   vbExclamation, "Invalid Time Entry"
            Cancel = True
        End If
    End Sub
    Change the message text to suit.

  3. #3
    Forum Contributor
    Join Date
    09-14-2012
    Location
    Tucson, Arizona, USA
    MS-Off Ver
    Office 2010
    Posts
    105

    Re: Problems Making A Userform Textbox Continue To Flash More Than 3 Times

    I apologize for taking so long to get back this.

    AlphaFrog, that actually works much better and is far more annoying, which is what I was trying to achieve. Thank you.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Problems Making A Userform Textbox Continue To Flash More Than 3 Times

    You're welcome. Glad it worked for you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1