On the first day of January every year, I want to run a module to backup DB and then delete all records. If the date is not 1st January, then it should give a message. I want to achieve this with the click of button. I put the following code in the OnClick event of the button but it is not working. Could you please suggest a remedy?
If Date = 1 - 1 - Year(Date) Then
BackupAndZipit
Dim db As Database, rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tblAllDet")
db.Execute "DELETE * FROM [tblAllDet];"
rs.Close
db.Close
Else
End If
Dim intResponse As Integer
Dim strMsg As String
strMsg = "This action cannot be executed now"
intResponse = MsgBox(strMsg, vbOKOnly)
If intResponse = vbOK Then
DoCmd.Close
Else
End If
If Date = 1 - 1 - Year(Date) Then
BackupAndZipit
Dim db As Database, rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tblAllDet")
db.Execute "DELETE * FROM [tblAllDet];"
rs.Close
db.Close
Else
End If
Dim intResponse As Integer
Dim strMsg As String
strMsg = "This action cannot be executed now"
intResponse = MsgBox(strMsg, vbOKOnly)
If intResponse = vbOK Then
DoCmd.Close
Else
End If