abbaddon223
Registered User.
- Local time
- Today, 08:36
- Joined
- Mar 13, 2010
- Messages
- 162
Hi,
I'm trying to setup a process of opening a form, saving to a location, emailing it as a PDF, killing the PDF, move onto the next form - rinse wash repeat until done.
The below works fine on a single click, however if I try to set it as an event timer of loop, I get an error saying: This action cannot be carried out whilst processing a form or report event.
Any help really appreciated!!!!! :banghead:
Do
Dim outputFileName, Ref As String
Ref = Vici_URN
outputFileName = CurrentProject.Path & "\Claim Packages\CICA\" & Ref & " - " & Format(Date, "yyyyMMdd") & ".pdf"
DoCmd.OutputTo acOutputForm, "Frm_CICA_Bulk_Send", acFormatPDF, outputFileName
Dim Attach As String
Attach = outputFileName
Dim iCfg As Object
Dim iMsg As Object
Set iCfg = CreateObject("CDO.Configuration")
Set iMsg = CreateObject("CDO.Message")
With iCfg.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") =
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") =
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") =
.Item("http://schemas.microsoft.com/cdo/configuration/sendemailaddress") =
.Update
End With
With iMsg
.Configuration = iCfg
.Subject = "Hotkey Transfer From"
.To =
.CC = ""
.BCC = "phil.little@.co.uk"
.TextBody = "Please find the enclosed customer details for Hotkey Transfer"
.AddAttachment Attach
.Send
End With
Set iMsg = Nothing
Set iCfg = Nothing
Kill outputFileName
[CurrentState] = "Sent"
DateSent = Date
TimeSent = Time()
DoCmd.GoToRecord acDataForm, "Frm_CICA_Bulk_Send", acNext
Loop
I'm trying to setup a process of opening a form, saving to a location, emailing it as a PDF, killing the PDF, move onto the next form - rinse wash repeat until done.
The below works fine on a single click, however if I try to set it as an event timer of loop, I get an error saying: This action cannot be carried out whilst processing a form or report event.
Any help really appreciated!!!!! :banghead:
Do
Dim outputFileName, Ref As String
Ref = Vici_URN
outputFileName = CurrentProject.Path & "\Claim Packages\CICA\" & Ref & " - " & Format(Date, "yyyyMMdd") & ".pdf"
DoCmd.OutputTo acOutputForm, "Frm_CICA_Bulk_Send", acFormatPDF, outputFileName
Dim Attach As String
Attach = outputFileName
Dim iCfg As Object
Dim iMsg As Object
Set iCfg = CreateObject("CDO.Configuration")
Set iMsg = CreateObject("CDO.Message")
With iCfg.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") =
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") =
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") =
.Item("http://schemas.microsoft.com/cdo/configuration/sendemailaddress") =
.Update
End With
With iMsg
.Configuration = iCfg
.Subject = "Hotkey Transfer From"
.To =
.CC = ""
.BCC = "phil.little@.co.uk"
.TextBody = "Please find the enclosed customer details for Hotkey Transfer"
.AddAttachment Attach
.Send
End With
Set iMsg = Nothing
Set iCfg = Nothing
Kill outputFileName
[CurrentState] = "Sent"
DateSent = Date
TimeSent = Time()
DoCmd.GoToRecord acDataForm, "Frm_CICA_Bulk_Send", acNext
Loop