Help with on timer event

  • Thread starter Thread starter vanessa
  • Start date Start date
V

vanessa

I have on timer event that is triggered every 8 seconds.
It does a requery of the underlying recordsource of the
form so that new records are shown, if there are any...
I have a function that can play a wav file and I would
like to be able to call that function whenever a new
record appears on the form. so i.e. when you currently
have 2 records in the form and after the requery a 3rd
record appears the fucntion should be called.
Does anyone has any idea's on how this could be
accomplished? TIA.
 
Before executing the requery, check the forms RecordsetClone.RecordCount
property, and store the value in a variable. After the requery, compare the
new RecordCount to the old one. If they're different, call your function.
Something like (untested) ...

Dim lngRecords as Long

lngRecords = Me.RecordsetClone.RecordCount
Me.Requery
If Me.RecordsetClone.RecordCount <> lngRecords Then
'call your function
End If
 
Thanks . will try this out!
-----Original Message-----
Before executing the requery, check the forms RecordsetClone.RecordCount
property, and store the value in a variable. After the requery, compare the
new RecordCount to the old one. If they're different, call your function.
Something like (untested) ...

Dim lngRecords as Long

lngRecords = Me.RecordsetClone.RecordCount
Me.Requery
If Me.RecordsetClone.RecordCount <> lngRecords Then
'call your function
End If

--
Brendan Reynolds (MVP)
(e-mail address removed)





.
 
Hi Vanessa:

How about comparing the number of records in the underlying recordset
at the beginning of the timer event with the number after the requery?
Perhaps something like the following would work:

Dim lngStartRecords as Long
Dim lngEndRecords As Long

Me.RecordsetClone.RecordCount = lngStartRecords
Me.Requery
Me.RecordsetClone.RecordCount = lngEndRecords

If lngEndRecords > lngStartRecords Then
Call wavefilefunction
End If

No guarantees, but might be worth a try.

John
 
John O. Graybill said:
Hi Vanessa:

How about comparing the number of records in the underlying recordset
at the beginning of the timer event with the number after the requery?
Perhaps something like the following would work:

Dim lngStartRecords as Long
Dim lngEndRecords As Long

Me.RecordsetClone.RecordCount = lngStartRecords
Me.Requery
Me.RecordsetClone.RecordCount = lngEndRecords

If lngEndRecords > lngStartRecords Then
Call wavefilefunction
End If

No guarantees, but might be worth a try.

John
 
Back
Top