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?


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
Application.FollowHyperlink strAttachTemp 

Open in new window

(you don't need both strAttachTemp and strOutputToTemp -- they are the same)

if it doesn't open, you probably need to put code in to wait a few seconds.  Ask and it shall be given :) ~

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gdunn59Author Commented:
Thanks that worked great!
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
you're welcome ;) ~ happy to help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.