Link to home
Start Free TrialLog in
Avatar of gdunn59
gdunn59

asked on

Why I'm getting error when trying to open report just created

I'm using the following code (see below) to create a PDF report of the data on the screen at the time.

When trying to open the report, I get an error saying that the report name is misspelled or doesn't exist.  If I check the directory it did create the PDF report.

I'm trying to open the newly created report.

Here is the code I'm using:

Private Sub cmdEmailRpt_Click()
On Error GoTo Err_cmdEmailRpt_Click


Dim strAttachTemp As String
Dim strOutputToTemp As String

' check to see if folder c:\users exists on user's hard drive, if not, create
    If Len(Dir("C:\Users\gm\Documents\Consultant", vbDirectory)) = 0 Then
        MkDir "C:\Users\gm\Documents\Consultant"
    End If

strOutputToTemp = "C:\Users\gm\Documents\Consultant\Audit " & "_" & InquiryNum & ".PDF"

strAttachTemp = strOutputToTemp

'''Output to Temp Area (to C Drive)
DoCmd.OutputTo acOutputReport, "rptAudit_Emails", acFormatPDF, strOutputToTemp, False

DoCmd.OpenReport strAttachTemp, acViewPreview


What is the problem?

Thanks,

gdunn59
ASKER CERTIFIED SOLUTION
Avatar of crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gdunn59
gdunn59

ASKER

Thanks that worked great!
you're welcome ;) ~ happy to help