2501 error with pdf file

jasn_78

Registered User.
Local time
Today, 19:15
Joined
Aug 1, 2001
Messages
214
Hey guys i have the following code where depending on an option i choose off a form exports a report to various options.

All works ok until i try to use option 4 first then repeat using option 3 at which point i geta runtime 2501 error

So any ideas why would be great.
Code:
Select Case rpttype
    Case Is = 1
        'this option outputs the the relevant report at 100% zoom in print preview mode
        DoCmd.OpenReport strrpt, acViewPreview
        DoCmd.RunCommand acCmdZoom100
        DoCmd.Maximize
    Case Is = 3
        'this option creates the report then outputs it to a pdf format
        'the file is titled the name of the report and todays date formatted to ddmmyy
        'DoCmd.OpenReport strrpt, acViewPreview
        DoCmd.OutputTo acOutputReport, strrpt, acFormatPDF, "C:\TFRS REPORTS\" & strrpt & today & ".PDF"
        DoCmd.Close
    Case Is = 4
        'this option outputs the report to a pdf document then emails it to certain email addresses
        Set objMessage = CreateObject("CDO.Message")
        objMessage.Configuration.Fields.Item _
        ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        objMessage.Configuration.Fields.Item _
        ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.bigpond.com"
        objMessage.Configuration.Fields.Item _
        ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
        objMessage.Configuration.Fields.Update
        objMessage.subject = subject
        sendto = InputBox("Enter email addresses with a ; as the seperator", _
                    "EMAIL ADDRESSES", "jason.smith@tfrs.com.au")
                    
        objMessage.from = "TFRS CUSTOM REPORTS <tfrsreports@tfrs.com.au>"
        objMessage.to = sendto
        objMessage.Bcc = ""
        objMessage.CC = ""
        objMessage.TextBody = "TFRS CUSTOM REPORTS"
        DoCmd.OutputTo acOutputReport, strrpt, acFormatPDF, "C:\TFRS REPORTS\" & strrpt & today & ".PDF"
        DoCmd.Close
        objMessage.AddAttachment "C:\TFRS REPORTS\" & strrpt & today & ".PDF"
        objMessage.Send
End Select
 
nevermind

nevermind guys seems like it was keeping some sort of lock on the file so when i then set the form to close after each option chosen all was fine :)
 

Users who are viewing this thread

Back
Top Bottom