I have a button that opens an email to an employee, however when the email window is open the Access window can't be clicked until the email is either sent or closed. This is a problem, because I also want to click a button in Access to open a certain folder and drop that into the email.
Here is my current code
Code:
Private Sub ButtonSentToFiscal_Click()
Dim varName As Variant
Dim varCC As Variant
Dim varSubject As Variant
Dim varBody As Variant
varName = PacketEmail
varCC = "V21sfcconference@va.gov"
'separate each email by a ','
varSubject = Me.Event & " packet approved"
'Email subject
varBody = Me.Identification & ", your conference/travel packet for " & Me.Event & " on " & Me.DateStart & " has been approved by the Office of the Director." & vbCrLf _
& vbCrLf & "If your packet involves registration reimbursement, you will receive a reimbursement packet once a purchase order is generated. If your event is in a future fiscal quarter, the reimbursement packet will arrive in the first week of the quarter, otherwise it will arrive within two weeks of this email. Fiscal Quarters are October through December, January through March, April through June, and July through September." & vbCrLf & "If your packet involves travel reimbursement, the packet has been forwarded to the travel office which will contact you to arrange travel." & vbCrLf & vbCrLf & _
"Office of Education" & vbCrLf & "V21SFCConference@va.gov"
'Body of the email
DoCmd.SendObject , , , varName, varCC, , varSubject, varBody, True, False
'Send email command. The True after "varBody" allows user to edit email before sending.
'The False at the end will not send it as a Template File
Me.DateSentToFiscal = Date
Me.Refresh
End Sub
As far as I can tell, what's happening is that while the email is still open, Access is still in the middle of executing a script and thus isn't available for activity. So perhaps what I need is for the script to not 'stop and wait' for the email, but rather proceed to the next step. What do I need to change?
And yes, I know I need to get some error handling in there. Right now if I close the email, it gives a big warning message prompting to end or debug. That's next on my agenda.