Howdy! I've been running an automation process for a Roadmap Database, but have been unable to filter records to hide records from within for months of being deployed. There is a "Deployment Date" field (please forgive the space for I have sinned) which details the date in long time of when the server was originally deployed. In VBA, I have a module which copies data from a Read-Only ODBC Table WIth conditions, adds rows, imports data from another table, and then is supposed to filter out those from within 4 months. its code is here:
Function ExportENGRFiltered4months()
DoCmd.SetWarnings False
DoCmd.Close acTable, "table2", acSaveNo
DoCmd.Close acTable, "dbo_ENGR_Info", acSaveYes
DoCmd.DeleteObject acTable, "Server2"
CurrentProject.Connection.Execute "SELECT * INTO table2 FROM table1 WHERE [Status]= 'Build' AND [Deployment Date] IS NOT NULL"
CurrentProject.Connection.Execute "Alter Table Server2 Add Column `ENGREmail` TEXT(50)"
Dim vSql As Variant
Dim vSqls As Variant
Dim strSql As String
Dim intF As Integer
intF = FreeFile()
Open "C:\sql.txt" For Input As #intF
strSql = Input(LOF(intF), #intF)
Close intF
vSql = Split(strSql, ";")
On Error Resume Next
For Each vSqls In vSql
CurrentDb.Execute vSqls
Next
CurrentProject.Connection.Execute "Alter Table Table2 Add Column `Active` bit"
DoCmd.OpenTable "Table2", acViewNormal, acEdit
'Dim str1 As Date
'Dim strFilter As String
'strFilter = "Status = '" & Build & "'"
'strFilter = strFilter & "And [Deployment Date] <" & "'" & str1 & "'"
'strFilter = strFilter & "And [Deployment Date] Is Not Null"
'DoCmd.SetFilter Wherecondition:=Chr(34) & strFilter & Chr(34)
DoCmd.SetWarnings True
Dim str1 As String
str1 = Format(Date, "Long Time")
str1 = DateAdd("M", -4, str1)
DoCmd.SetFilter WhereCondition:="[Deployment Date]" & "<" & Chr(34) & str1 & Chr(34)
End Function
All of this works, except for the date filter. It'll Deselect all dates, but still show all information. has anyone seen this issue before? and/or if so/if anyone has any advice, please let me know. Thank Y'all in Advance!
Function ExportENGRFiltered4months()
DoCmd.SetWarnings False
DoCmd.Close acTable, "table2", acSaveNo
DoCmd.Close acTable, "dbo_ENGR_Info", acSaveYes
DoCmd.DeleteObject acTable, "Server2"
CurrentProject.Connection.Execute "SELECT * INTO table2 FROM table1 WHERE [Status]= 'Build' AND [Deployment Date] IS NOT NULL"
CurrentProject.Connection.Execute "Alter Table Server2 Add Column `ENGREmail` TEXT(50)"
Dim vSql As Variant
Dim vSqls As Variant
Dim strSql As String
Dim intF As Integer
intF = FreeFile()
Open "C:\sql.txt" For Input As #intF
strSql = Input(LOF(intF), #intF)
Close intF
vSql = Split(strSql, ";")
On Error Resume Next
For Each vSqls In vSql
CurrentDb.Execute vSqls
Next
CurrentProject.Connection.Execute "Alter Table Table2 Add Column `Active` bit"
DoCmd.OpenTable "Table2", acViewNormal, acEdit
'Dim str1 As Date
'Dim strFilter As String
'strFilter = "Status = '" & Build & "'"
'strFilter = strFilter & "And [Deployment Date] <" & "'" & str1 & "'"
'strFilter = strFilter & "And [Deployment Date] Is Not Null"
'DoCmd.SetFilter Wherecondition:=Chr(34) & strFilter & Chr(34)
DoCmd.SetWarnings True
Dim str1 As String
str1 = Format(Date, "Long Time")
str1 = DateAdd("M", -4, str1)
DoCmd.SetFilter WhereCondition:="[Deployment Date]" & "<" & Chr(34) & str1 & Chr(34)
End Function
All of this works, except for the date filter. It'll Deselect all dates, but still show all information. has anyone seen this issue before? and/or if so/if anyone has any advice, please let me know. Thank Y'all in Advance!