Open form when tables contents change (1 Viewer)

tacieslik

Registered User.
Local time
Today, 04:03
Joined
May 2, 2001
Messages
244
I need to open a form when a tables contents change. I'm only ever dealing with a few records and I want a form to be displayed when the tables contents are displayed? Anyone go any ideas?

TIA
 

tacieslik

Registered User.
Local time
Today, 04:03
Joined
May 2, 2001
Messages
244
Would it be possible to have some code that sits in a loop doing a record count. This value could then be compared against the last value or zero to determine if the form is displayed? If this is possible, could anyone get me started?

Many Thanks in advance.

T
 

Tay

likes garlic
Local time
Today, 04:03
Joined
May 24, 2002
Messages
269
What exactly do you mean by "when a tables contents change"?. Do you mean whether or not a new record has been added, or do you mean if the data in a field has changed or been added? And also, would you not be entering/editing the data in that table by a form? So, if the data in table1/form1 has been altered, then display form2?
If so, then on form1 you could use the .dirty property which will tell you if anything has changed.
 

tacieslik

Registered User.
Local time
Today, 04:03
Joined
May 2, 2001
Messages
244
Thanks for the reply Tay,

The tables data is being updated by a separate program. I only need to know if the table has had a new record added.

Hope this will help you help me.
 

tacieslik

Registered User.
Local time
Today, 04:03
Joined
May 2, 2001
Messages
244
So far this is what I've managed to code:

Code:
Function ListenForLabels()

Dim db As Database
Dim rs As Recordset
Dim CaptureRecCount As Integer

Set db = CurrentDb()
Set rs = db.OpenRecordset("tblCapture")

    With rs
    .MoveFirst
    .MoveLast
    CaptureRecCount = .RecordCount

    If CaptureRecCount > 0 Then
    DoCmd.OpenForm "frmProcessHidden", , , , , acHidden
    DoCmd.OpenForm "frmProcess"
    End If
        
    End With
        
     
End Function

This works fine when you manually run the code, but I want it to be constantly counting the records and to stop if they equal zero.
Hope this makes sense
T
 
Last edited:

Users who are viewing this thread

Top Bottom