MS Access DoCmd.TransferText acExportDelim But For Creating New Files Not Existing Files.

I am familiar with using DoCmd.TransferText acExportDelim for exporting and writing over a EXISTING CSV file in a folder but what would I use to write a new file if it was not there?  

If Dir("C:\DailyExport\NewExport.CSV") <> "" Then
DoCmd.TransferText acExportDelim, "ExportToComExportSpecification2", "ComExportNewTemp", "C:\DailyExport\NewExport.CSV", True
   Else
    ' put code here to elicit a new file name or you can add a number on to the name
End If
    

Open in new window


Thanks for the help.
LVL 1
Dustin StanleyEntrepreneurAsked:
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.

bfuchsCommented:
what happens if you use same code as if exists? perhaps it will create the file for you..
0

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
Gustav BrockCIOCommented:
what would I use to write a new file if it was not there?

Nothing else. The file will simply be created.
0
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
Usually with most operations you have the opposite problem; if the file is already there, you have a problem because the operation fails or you get a warning.  The way around that is to delete  (VBA Kill) the file first if it exists.

 So like the others, not sure I understand what the issue is.

Jim.
0
Dale FyeCommented:
Are you asking how to open the file dialog to allow you to browse you computer, select a folder, and assign a file name, as you would when saving a Word, Excel, or Access database?  If so, you will need a reference to the Microsoft Office ##.0 Object Library, and then code similar to that seen in this article.
0
Dustin StanleyEntrepreneurAuthor Commented:
It didn't seem right to me either but there must had been some underlying issue that worked out. It was giving me an error but now it just creates it fine. Boggling but it works now. Thanks for the help.
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.