SpectacledBear
Programmer
I currently have this code on my archive form:
Private Sub cmdTime_Click()
On Error GoTo Err_cmdTime_Click
Dim db As DAO.Database
Set db = CurrentDb
If Not IsNull(Me!txtTime) Or Not Me!txtTime = "" Then
Dim stDocName As String
If lst2 = "Deliveries" And txtTime = Time() Then
DoCmd.RunMacro mcrDeliveryArchive
Else
If lst2 = "Orders" And txtTime = Time() Then
DoCmd.RunMacro mcrOrderArchive
Else
If lst2 = "Sales" And txtTime = Time() Then
DoCmd.RunMacro mcrSalesArchive
End If
End If
End If
Else
MsgBox "You have not selected a correct time to complete archives", vbCritical + vbOKOnly, "Error"
Me!txtTime.SetFocus
db.Closee
Set db = Nothing
Exit Sub
End If
db.Close
Set db = Nothing
MsgBox "Table(s) archived successfully.", vbInformation
Me!txtTime.Requery
Exit_cmdTime_Click:
Exit Sub
Err_cmdTime_Click:
If Err = 3021 Then
Resume Next
Else
MsgBox Err.Description
Resume Exit_cmdTime_Click
End If
End Sub
I want the code to check if the calue of txtTime is now, and the value of the listbox is deliveries, to run the delivery archive macro etc. I typed in this code, and it is not working. Please can anyone offer any suggestioons as to how I can make this happen?
Private Sub cmdTime_Click()
On Error GoTo Err_cmdTime_Click
Dim db As DAO.Database
Set db = CurrentDb
If Not IsNull(Me!txtTime) Or Not Me!txtTime = "" Then
Dim stDocName As String
If lst2 = "Deliveries" And txtTime = Time() Then
DoCmd.RunMacro mcrDeliveryArchive
Else
If lst2 = "Orders" And txtTime = Time() Then
DoCmd.RunMacro mcrOrderArchive
Else
If lst2 = "Sales" And txtTime = Time() Then
DoCmd.RunMacro mcrSalesArchive
End If
End If
End If
Else
MsgBox "You have not selected a correct time to complete archives", vbCritical + vbOKOnly, "Error"
Me!txtTime.SetFocus
db.Closee
Set db = Nothing
Exit Sub
End If
db.Close
Set db = Nothing
MsgBox "Table(s) archived successfully.", vbInformation
Me!txtTime.Requery
Exit_cmdTime_Click:
Exit Sub
Err_cmdTime_Click:
If Err = 3021 Then
Resume Next
Else
MsgBox Err.Description
Resume Exit_cmdTime_Click
End If
End Sub
I want the code to check if the calue of txtTime is now, and the value of the listbox is deliveries, to run the delivery archive macro etc. I typed in this code, and it is not working. Please can anyone offer any suggestioons as to how I can make this happen?