Need to prompt to save file from VBA if file exists

I have a function to create and save a PDF file. The file name is the company name + the date. The creates a "request " file. If two requests are amde for the same day, the first file gets overwritten. How do I prompt the user if the file name already exists?

Function email_binder()
        Dim db As Database
        Dim rs As DAO.Recordset
        Dim MyOutlook As Outlook.Application
        Dim MyMail As Outlook.MailItem
        Dim address As String
        Dim EmailTo As String
        Dim EmailCc As String
        Dim EmailSubject As String
        Dim EmailMsg As String
        Dim EmailAttach As String
        Dim DisplayEmail As Boolean
        Dim spar1 As String
        Dim spar2 As String
        Dim spar3 As String
        Dim spar4 As String
        Dim Cust As String
        Dim strAttachment As String
        Dim strReport As String
        On Error Resume Next
        Cust = Form_Client.Text82
        address = Form_Client.Text115
        Set db = CurrentDb
        Set rs = db.OpenRecordset("SELECT * " & _
                                "FROM info " & _
                                "WHERE id = 1")
         strAttachment = Application.CurrentProject.Path & "\Requests\Request " & Cust _
        & " " & Format(Date, "m-d-yyyy") & ".pdf"

        Debug.Print "Attachment file name and path: " & strAttachment
        strReport = "rpt_request"
        DoCmd.OutputTo objecttype:=acOutputReport, _
        objectname:=strReport, _
        outputformat:=acFormatPDF, _

End function
There is more code for emailing the file, but this is the creation of the file.
Who is Participating?
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.

Joe HowardCommented:
If dir(strAttachment) <> "" then
' file exists
dgravittAuthor Commented:
So, if file exists, how would you pop up the save as box?
Joe HowardCommented:
strAttachment = Application.CurrentProject.Path & "\Requests\Request " & Cust _
        & " " & Format(Date, "m-d-yyyy") & ".pdf"
If dir(strAttachment) = "" then
    strAttachment  = SaveAsDialog()
end if

Function SaveAsDialog() As String
    Dim dlgSaveAs As Object
    Set dlgSaveAs = Application.FileDialog(2)
    With dlgSaveAs
        .InitialFileName = "C:\docs\this is the default name"
    End With
    SaveAsDialog = dlgSaveAs.SelectedItems(1)
End Function

Open in new window

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
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

dgravittAuthor Commented:
Thanks, just what I needed!
Joe HowardCommented:
Glad to help :)
dgravittAuthor Commented:
Just encountered an issue. This code works fine in Access 2010, but on an Access 2016 machine, it gives an error "Access has stopped working" and closes the application. Any ideas?
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

From novice to tech pro — start learning today.