Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Code needed to create a blank text file after a macro is done in Access

Posted on 2015-02-04
3
Medium Priority
?
207 Views
Last Modified: 2016-02-10
I have a macro that runs a series of 20-25 queries, a function at the end.  What is the VBA code for simply creating a blank text file and copying to a folder.

File Path:  C\MyShare
File Name Name Must be:  accessdone.txt

My developer wrote a code that emails reports when my macro is done, he wants a file dropped in a specific folder on our network with a specific name.

Is this possible?
0
Comment
Question by:gracie1972
3 Comments
 
LVL 18

Accepted Solution

by:
Simon earned 2000 total points
ID: 40589715
Add these lines to the bottom of your code.

 Dim fileNum As Long
Dim outputFile As String
    
fileNum = FreeFile 'Get the next free filehandle
Open "C:\MyShare\accessdone.txt" For Output As #fileNum 'open the file for writing
Close #fileNum 'close the output file.

Open in new window

0
 

Author Closing Comment

by:gracie1972
ID: 40590129
Thank You!
0
 
LVL 11

Expert Comment

by:HuaMinChen
ID: 40590157
Try
    Dim flsys
    Set flsys = CreateObject("scripting.filesystemobject")
    Set fl = flsys.createtextfile("C:\MyShare\accessdone.txt")

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question