Working with Loop or Interval in VB Access

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Stoic
    New Member
    • Jun 2012
    • 68

    Working with Loop or Interval in VB Access

    Thanks to NeoPa, Rabbit and TheSmileyCoder for the your assistance. Now that I have my lblProcessing label flashing on my OnTimer, I would like to control the number of times the label 'lblProcessing' will flash in my code.
    I have placed this code in the form OnTime but it doesn't work. What is does is stop the flashing, there is no error message.
    Code:
    Private Sub Form_Timer()
        With Me.lblProcessing
            .Visible = Not Me.lblProcessing.Visible + 5
        End With
    End Sub
    Any help will be appreciated.
    Thanks
  • Syed Hadi
    New Member
    • Dec 2012
    • 56

    #2
    you can use if statement .. i think it will work
    Code:
     If Timer1.Tag = True Then
               lblProcessing.ForeColor = Color.Black
                lblProcessing.BackColor = Color.White
                Timer1.Tag = False
            Else
                lblProcessing.ForeColor = Color.White
                lblProcessing.BackColor = Color.Black
                Timer1.Tag = True
            End If

    Comment

    • Syed Hadi
      New Member
      • Dec 2012
      • 56

      #3
      and even if u need just flashing then just use the flashing image
      with format .gif

      Comment

      • Stoic
        New Member
        • Jun 2012
        • 68

        #4
        Thanks Syed but that is not what I want. I have my form with several fields and I am getting the results which is after a particular field is updated, the timer is activated and the label flashes. Now that the label is flashing, I would like to control the number of times that the label flashes.
        These are my codes:
        Code:
        Private Sub cmdSubmit_Click()
            If Me.Number > 0 Then
                Me.TimerInterval = 500
            Else
                Me.TimerInterval = 0
                Me.lblProcessing.Visible = False
                MsgBox "Please complete the Number field and try submitting again"
                Me.Number.SetFocus
            End If
        End Sub
        
        Private Sub Form_Current()
            If Me.Number = "*" Then
                Me.TimerInterval = 500
            Else
                Me.TimerInterval = 0
                Me.lblProcessing.Visible = False
            End If
        End Sub
        
        Private Sub Form_Timer()
            With Me.lblProcessing
                .Visible = Not Me.lblProcessing.Visible
            End With
        End Sub

        Comment

        • Rabbit
          Recognized Expert MVP
          • Jan 2007
          • 12517

          #5
          Use a global variable to track the number of times it has flashed and stop the timer after that many flashes have elapsed.

          Comment

          • ADezii
            Recognized Expert Expert
            • Apr 2006
            • 8834

            #6
            @Rabbit:
            Wouldn't a Static Variable within the Timer() Event to control the Number of Flashes be a better Option then a Global?

            Comment

            • Rabbit
              Recognized Expert MVP
              • Jan 2007
              • 12517

              #7
              Static probably would be better. I don't use them much so it slipped my mind.

              Comment

              Working...