Now trying to close Access
I now want to have VBA or a Macro to close Access when it is finished running this.
What I have working (but not satisfactorily) is a command-line macro sitting in Window's Scheduled Tasks. This (Access) macro Opens a Form in Access, submitting the VBA code (below) and then Quits. But, it Quits Access too quickly. I can't figure out how to get a time feature into the macro (like 30 seconds). And, I tried inserting code at the end of my Sub (see red, below) but neither Form nor Access closes.
Do I have some nomenclature wrong....or am I better off using another Macro to close the db and Access?
I now want to have VBA or a Macro to close Access when it is finished running this.
What I have working (but not satisfactorily) is a command-line macro sitting in Window's Scheduled Tasks. This (Access) macro Opens a Form in Access, submitting the VBA code (below) and then Quits. But, it Quits Access too quickly. I can't figure out how to get a time feature into the macro (like 30 seconds). And, I tried inserting code at the end of my Sub (see red, below) but neither Form nor Access closes.
Do I have some nomenclature wrong....or am I better off using another Macro to close the db and Access?
Private Sub Form_Load()
Dim rst As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb
Set rst = db.OpenRecordset("qryEmail_Notif_NIEHS")
Dim dtOne As Date
Dim dtDue As Date
Dim strproject As String
Dim strprotocol As String
Dim strstudymgr As String
dtOne = Date 'todays date
Do While Not rst.EOF
dtDue = rst!dtmNPacketDue
strproject = rst!strBrochureName
strprotocol = rst!strNIHProtocolNum
strstudymgr = rst!strSMName
If dtDue > dtOne + 120 Then
DoCmd.SendObject , , , "xxxx@nnn.gov", , , "NIEHS Due Date Approaching", _
"The NIEHS packet due date for " & strproject & ", " & strprotocol & ", is: " & vbCrLf & vbCrLf & dtDue _
& vbCrLf & "which is XX weeks from today. Please make a note of it." _
& vbCrLf & vbCrLf & "IRB coordinator" & vbCrLf & "Elizabeth O'Connell", False
End If
rst.MoveNext
Loop
rst.Close 'does not close Form
db.Close 'does not close Access
End Sub
Dim rst As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb
Set rst = db.OpenRecordset("qryEmail_Notif_NIEHS")
Dim dtOne As Date
Dim dtDue As Date
Dim strproject As String
Dim strprotocol As String
Dim strstudymgr As String
dtOne = Date 'todays date
Do While Not rst.EOF
dtDue = rst!dtmNPacketDue
strproject = rst!strBrochureName
strprotocol = rst!strNIHProtocolNum
strstudymgr = rst!strSMName
If dtDue > dtOne + 120 Then
DoCmd.SendObject , , , "xxxx@nnn.gov", , , "NIEHS Due Date Approaching", _
"The NIEHS packet due date for " & strproject & ", " & strprotocol & ", is: " & vbCrLf & vbCrLf & dtDue _
& vbCrLf & "which is XX weeks from today. Please make a note of it." _
& vbCrLf & vbCrLf & "IRB coordinator" & vbCrLf & "Elizabeth O'Connell", False
End If
rst.MoveNext
Loop
rst.Close 'does not close Form
db.Close 'does not close Access
End Sub