Forum Discussion

Cyber_Learning's avatar
Cyber_Learning
Copper Contributor
Mar 08, 2023

Timer Event Popup Reminder

Hello Forum Members

I currently have the following Timer event, which is working.

The "valid" is valid dates in a table.

If the valid date is passed, the Timer event kicks in.

But, I also want to show the records that expire in 5 months from the valid date are older than today.

For example, today is 03/08/2023 and if there are valid dates as:

05/01/2023: should show up. (as it becomes 01/01/2023, 5 months from the valid date)

07/01/2023: should show up. (as it becomes 02/01/2023, 5 months from the valid date)

11/01/2020: no need to show up. (as it becomes 06/01/2023, 5 months from the valid date)

12/01/2023:  no need to show up. (as it becomes 07/01/2023, 5 months from the valid date)

Would you please help me on this task?

 

Thank you.

/ code starts here. /

Private Sub Form_Timer()

Dim ID As Long

ID = Nz(DLookup("ID", "CPR_Biopsy", "Valid<=#" & Date & "#"), 0)
If ID <> 0 Then
DoCmd.OpenForm "CPR_Biopsy_Notice"
End If

End Sub

/ code stops here. /

 

  • arnel_gp's avatar
    arnel_gp
    Steel Contributor
    try this code:

    Private Sub Form_Timer()

    Dim ExpiredCount As Long

    ExpiredCount = DCount("1", "CPR_Biopsy", "Valid <= #" & Format$(DateAdd("m", 5, Date), "mm/dd/yyyy") & "#")

    If ExpiredCount <> 0 Then
    'Kill the timer
    Me.TimerInterval = 0
    DoCmd.OpenForm "CPR_Biopsy_Notice"
    End If

    End Sub

Resources