• Flashing Label (Access 2002)

    Author
    Topic
    #392241

    Hey Gang,
    I am building a database that tracks insurances on Facilities my company owns and we have to monitor for compliance. There are 11 type of insurance for each facility. I want to write some code that will cause a Label to flash when the [InsuranceReq] field is greater than the [InsuranceCov] field. The label will be on the parent form and the fields on a subform. I have tried this but to no avail:

    Private Sub Form_Current()

    If Me![frmFacIns].Form [InsuranceReq] > [InsuranceCov] Then
    Me.TimerInterval = 300
    Else
    Me.TimerInterval = 0
    Me.lblFlag.ForeColor = vbBlack
    End If

    I am new to the programming stuff so any help would be great.

    Thanks,

    Dan

    Viewing 1 reply thread
    Author
    Replies
    • #703388

      Personally, I would hate a label flashing at me, but that’s a matter of taste grin.

      You need several procedures for this:

      1. A procedure to start/stop the flashing:

      Private Sub StartStopFlashing()
      If Me.InsuranceReq > Me.InsuranceCov Then
      ‘ Flashing on
      Me.TimerInterval = 300 ‘ in milliseconds
      Else
      ‘ Flashing off
      Me.TimerInterval = 0
      End If
      End Sub

      Call this from the On Current event of the form and the After Update event of InsuranceReq and InsuranceCov:

      Private Sub Form_Current()
      StartStopFlashing
      End Sub

      Private Sub InsuranceCov_AfterUpdate()
      StartStopFlashing
      End Sub

      Private Sub InsuranceReq_AfterUpdate()
      StartStopFlashing
      End Sub

      2. A procedure to perform the actual flashing. This is the On Timer event handler:

      Private Sub Form_Timer()
      If Me.lblFlag.ForeColor = vbBlack Then
      Me.lblFlag.ForeColor = vbRed
      Else
      Me.lblFlag.ForeColor = vbBlack
      End If
      End Sub

      Adapt the colors to your wishes.

    • #703448

      Hans,

      Thank you for your help. I agree a flashing label is going to be annoying and hopefully I can get them to go to a visible/hidden label instead. I was unable to get the lable to flash on the Main Form only on the subform where my fields are. I believe it is because I am using the “ME” the identifier. I am not sure how to get it to call the Label on the main form after many efforts.

      Anymore advice??

      Thanks,

      Dan

      • #703454

        You can refer to a control on the main form by using Me.Parent.lblFlag
        Parent refers to the form one level up, in this case the main form.

    Viewing 1 reply thread
    Reply To: Flashing Label (Access 2002)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: