Log in

View Full Version : Solved: Automatically run a sub



paulked
09-01-2009, 11:39 AM
Hi

I have a database which, amongst other things, is logging process values from a PLC.

The process sends 48 fields of data to a Log table every second. One of these fields is the "LogData" field.

I have written code that exports the logged data as an xls file and then clears the Log table.

I would like this code to run as soon as the LogData field changes from 1 to 0.

Any ideas? :dunno

Many thanks

Paul Ked

Movian
09-01-2009, 11:53 AM
What is processing this data each second ? some VBA in your database or an external source ?

Also in this table from the sounds of it there will only ever be one record in the table at a time ?

paulked
09-01-2009, 12:35 PM
An external plc gathers the field data and pushes it every second via a MES unit (sql) into an access table. This data is inserted into the table so after 20 mind of logging there will be 1200 records in the table.

Cheers

Paul Ked

Movian
09-01-2009, 02:05 PM
My suggestion would be to have a hidden form with an on timer event to check the table at your preset time intervals to check the field and then run the sub when applicable.

paulked
09-01-2009, 02:09 PM
Cheers

I'm actually giving that a go at the moment.

I'll let you know how I get on.

Paul Ked

paulked
09-01-2009, 02:20 PM
how do I update the form every second so that the text box contains the latest information?

I'm trying
Dim ctlText As Control
Set ctlText = Forms!Trigger1!StopLig1
ctlText.Requery
but that doesn't work?

Many thanks

Paul Ked

paulked
09-01-2009, 05:16 PM
I got it sorted. I used a query to sort and the DoCmd.ShowAllRecords triggered by the Form_Timer to update.

Thanks for your help.

Cheers

Paul Ked