Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Mar 2002
    Location
    Ventura, California, USA
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Flashing Label (Access 2002)

    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

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Flashing Label (Access 2002)

    Personally, I would hate a label flashing at me, but that's a matter of taste <img src=/S/grin.gif border=0 alt=grin width=15 height=15>.

    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.

  3. #3
    Star Lounger
    Join Date
    Mar 2002
    Location
    Ventura, California, USA
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Flashing Label (Access 2002)

    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

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Flashing Label (Access 2002)

    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.

Posting Permissions

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