Play sound on new record in report

Hi

I am using the following code to create a flash on the PStatus field within my form. The form is a tabular list of many records and I only want the records with a P1 text in the Pstatus field to flash but all feilds are flashing:

Private Sub Form_Timer()

Me.Requery

If [PStatus] = "P1" Then
If [PStatus].ForeColor = vbBlack Then
[PStatus].ForeColor = vbRed
Else
[PStatus].ForeColor = vbBlack

End If
End If
End Sub

Is it possible what I am trying to do?

Thanks
 
Oops, guess it's not that simple after all. Do you have Access 2010 or later? Maybe we can figure out something using conditional formatting.
 
I use MS Access 2013. 32 bit.
Having read the recent comments I am now questioning whether I should be using a report or form to display the required information.

Thanks
 
Please hold off on any change to a form until I've had a chance to look at this further. I didn't seen anything in those comments that justified a change to a form other than the assertion that some events don't fire. Now that I know you have conditional formatting I will see if I can't figure out how to make it blink.


In the mean time would you see if you can get the basic conditional formatting working. It shouldn't be hard. Just open the report in design view, click on the PStatus field, in the FORMAT tab of the ribbon click Conditional Formatting, New Rule and set it up like shown below, i.e., Field Value equal to P1 and apply the formatting. You can change the forecolor, backcolor, make it bold etc.

attachment.php
 

Attachments

  • Conditional Formatting.jpg
    Conditional Formatting.jpg
    42.3 KB · Views: 348
Basic formatting in place and working fine. Just the flash.

Just another quick one. Is it possible to have 2 timer events with different intervals.

What happens if you wanted a requery every 10 minutes but a different timed event every 5 minutes for example.

Thanks
 
I'm glad you asked that question. There is only one timer event per form or report. I have an application that uses three timers (on three different forms) running a the same time at difference intervals without any problems but if you are already using the report timer to requery the report it might be tricky to use the same timer to make it flash.

Maybe we can use a separate form to do the flashing. My idea is to programmatically add and delete the conditional formatting with a timer. I hope to get this working today but I don't know what the results will look like. This process may not be fast enough to get a reasonable flash.
 
The code for turning conditional formatting on and off is:

Code:
Private Sub SwitchFormat()

Dim ctrl As Control
Dim ReportName As String
ReportName = "[COLOR="Blue"]Report1[/COLOR]"

If Not (CurrentProject().AllReports(ReportName).IsLoaded) Then
    Exit Sub
End If
Set ctrl = Reports(ReportName).Controls("PStatus")
If ctrl.FormatConditions.Count > 0 Then
    ctrl.FormatConditions.Delete
Else
    ctrl.FormatConditions.Add acFieldValue, acEqual, "'P1'"
    ctrl.FormatConditions.Item(0).ForeColor = vbRed
End If

End Sub

This can be placed in a forms timer event to turn the format on and off in the report. This is set up with the condition PStatus = "P1". You will need to change the Report1 in this to the name of your report. Before you do any of that I suggest you try this in the attached database to see if you want it. You can set the time in frmFlasher to see this operate in Report1. I've found that it doesn't handle a time like 0.2 seconds very well. 0.5 Seconds seems ok but you can see a strobing effect from top to bottom as it updates the records.
 

Attachments

Users who are viewing this thread

Back
Top Bottom