Private Sub Form_Current()
If DateDiff("d", DMax("DateTime1", "ComCon", "FundName='" & Me.FundName & "'"), Date) > 90 Then
Me.lstAlerts.AddItem ("UpdateContacts, Update the contacts: it has been more than 90 days")
End If
If NewestFileInFolder(Me.Folder) >= 90 Then
Me.lstAlerts.AddItem ("UpdateFiles , Update the files: it has been more than 90 days")
' Me.lstAlerts.AddItem ("UpdateFiles , Update the files: it has been more than 90 days")
End If
End Sub
Private Sub Form_Load()
Dim intX As Integer
For intX = 0 To Me.lstAlerts.ListCount - 1
Me.lstAlerts.RemoveItem (intX)
Next intX
End Sub
Private Sub lstAlerts_DblClick(Cancel As Integer)
Select Case Me.lstAlerts.Value
Case "UpdateContacts"
DoCmd.OpenForm "comform", , , "FundName='" & Me.FundName & "'", , acDialog
End Select
End Sub
Public Function NewestFileInFolder(strFolderPath As String) As Integer
Dim objFSO As FileSystemObject, objFolder As Object, objFile As File, intTemp As Integer, bolFirstPass As Boolean
Set objFSO = CreateObject("Scripting.FileSystemobject")
Set objFolder = objFSO.GetFolder(strFolderPath)
bolFirstPass = True
For Each objFile In objFolder.Files
intTemp = DateDiff("d", objFile.DateCreated, Date)
If bolFirstPass Then
NewestFileInFolder = intTemp
bolFirstPass = False
Else
If intTemp < NewestFileInFolder Then NewestFileInFolder = intTemp
End If
Next
Set objFile = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
End Function
with help from
"Blue Devil Fan" and "DatabaseMX"
|