Hello,
I have a set of query's that I need to run each day off a button to update table. In VBA I am trying to ensure that the query's do not run multiple time on one day. I want to use an if statement that would compare the current date against a date field in a table to ensure that they do not mach before executing all the query's. The VBA below does not seem to be recognizing the SQL statement and is causing it to always think the process has been previously executed on that day.
Private Sub ExecuteQuerys_Click()
DoCmd.SetWarnings False
Dim db As Database
Dim t As DAO.Recordset
Dim SQL As String
Dim msg As String, Ans As Variant
Set db = CurrentDb()
SQL = "Select max(tbl_RSS.Today)from tbl_RSS"
If Date > SQL
Then
Ans = MsgBox("Are you sure you want to update report tables?", vbYesNo)
Select Case Ans
Case vbYes
DoCmd.OpenQuery "App"
DoCmd.OpenQuery "App"
DoCmd.OpenQuery "App"
DoCmd.OpenQuery "App"
DoCmd.OpenQuery "App"
DoCmd.OpenQuery "App"
DoCmd.OpenQuery "App"
DoCmd.OpenQuery "App"
DoCmd.OpenQuery "App"
DoCmd.OpenQuery "App"
MsgBox "Tables have been updated and are ready for validation", vbOKOnly, "Report Release"
Case vbNo
End Select
Else
MsgBox "Today's reports have already been updated, to validate data select report from below", vbCritical
End If
End Sub
Any help would be greatly appreciated!!!