Consulting

Results 1 to 5 of 5

Thread: Solved: Blinking field in UserForm

  1. #1

    Solved: Blinking field in UserForm

    I found a link where blinking fields were explained (http://help.wugnet.com/office/make-label-blink-ftopict1118942.html)

    However, using this technique, the field blinks anytime the userform is displayed. I want to turn on/off the blinking field based on the content of another field. For example, say that the user enters "abc" in myform.lblData1. I have a second field named myform.lblData2. When lblData1 is "abc", then I want lblData2 to blink.

    How do I dynamically turn ON/OFF the blinking of a field in a userform? TIA.

  2. #2
    VBAX Tutor
    Joined
    Sep 2007
    Posts
    265
    Location
    Not perfect but worked!

    [vba]Option Explicit
    Dim KillForm As Boolean

    Private Sub TextBox1_Change()
    Label10.Caption = TextBox1.Text
    End Sub
    Private Sub TextBox2_Change()
    Label8.Caption = TextBox2.Text
    End Sub
    Private Sub TextBox3_Change()
    Label11.Caption = TextBox3.Text
    End Sub
    Private Sub UserForm_Activate()
    MoveTitle
    End Sub
    Private Sub MoveTitle()
    Dim i As Long
    KillForm = False
    On Error Resume Next
    Ulangi:
    If KillForm = True Then Exit Sub
    Label10.Left = Label10.Left - 1
    Label11.Left = Label11.Left - 1
    Label8.Left = Label8.Left - 1

    If Int(Label10.Left) Mod 60 = 0 Then
    If Label11.ForeColor = &HFF00& Then
    Label11.ForeColor = &H80FFFF
    Else
    Label11.ForeColor = &HFF00&
    End If
    End If
    If Int(Label8.Left) Mod 60 = 0 Then
    If Label10.ForeColor = &HFF Then
    Label10.ForeColor = &HFFFFFF
    Else
    Label10.ForeColor = &HFF
    End If
    End If
    If Int(Label11.Left) Mod 60 = 0 Then
    If Label8.ForeColor = &HFF Then
    Label8.ForeColor = &HFFFFFF
    Else
    Label8.ForeColor = &HFF
    End If
    End If

    DoEvents
    For i = 1 To 800000: Next
    If Label10.Left + Label10.Width < 0 Then Label10.Left = Width
    If Label11.Left + Label11.Width < 0 Then Label11.Left = Width
    If Label8.Left + Label8.Width < 0 Then Label8.Left = Width

    GoTo Ulangi
    End Sub
    Private Sub UserForm_Terminate()
    KillForm = True
    End Sub

    Private Sub UserForm_Initialize()



    Label10.Caption = TextBox1
    Label11.Caption = TextBox2
    Label8.Caption = TextBox3


    End Sub
    [/vba]

  3. #3
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    Just a word to the wise: blinking cells cause program overhead. Also many users find them annoying (I think I remember Bob threatening to hunt down and beat anyone who made him use a spreadsheet with a blinking cell).

    A slightly less overt method could be simply highlighting the desired cell with a color that breaks it out from the rest of the sheet.
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


  4. #4

    Thanks for the replies

    I needed to see the code to do this, but after thinking about it, I decided that "blinking" was the wrong approach. So I'm going to turn the text red. That will get the idea across without the annoyance of the blinking. I thought about me and my inability to make decisions, sitting there, staring at a screen that was blinking... Another bad idea.

    Actually, I probably should turn the text red and make it blink two or three times.

    Thanks for the code and the ideas.

  5. #5
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    If you are simply trying to create a focus point on the form, why not create an instance where the field changes character(colour) after the form has focus?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

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