?
Solved

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

Posted on 2015-02-04
3
Medium Priority
?
165 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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

741 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