Solved

VBS to Read a Field from Access DB and Save as a Text File

Posted on 2012-04-12
3
326 Views
Last Modified: 2012-05-04
Greetings,
I created a query in MS Access 2007 database that looks for instances of any employees failing to enter their hours worked in our time/billing system. The query produces a table named MissedTime that has three fields (StaffID, CompName, and Email) of each employee who has failed to enter time on 1 or more days during the previous 7 days. What I need help with is writing a VBScript that will read or copy the contents of field 'CompName' of all records in the table and create a txt file containing that data. I already have a vbs file that will "net send" a reminder to a list of computer names in a text file. I just need help with creating the text file containing the data from Access. The company's payroll person spends too much time reminding people to enter their time and I've been tasked with automating the process.
Thanks in advance for your help.

Craig
0
Comment
Question by:CraigMan
3 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 37840210
you can export the table as text file using vba codes
first create an Export Specification

1.right click on the table
2.select export > Text file
   click on Browse and locate the destination folder
3. (you can accept the proposed name or change it)
click Save, then click OK
4. In the export text wizard select the type (Delim Fixed) width
5. Follow the wizard, before clicking on Finish
     5a .Click Advanced
6. In the Export Specification dialog box Field Information List, correct any descrepancies

7. click save as, give the specification a name <-- this is the specification name that you will use in the command line below


DoCmd.TransferText acExportDelim, "ExportSpecName", "TableName", "C:\myText.txt", True

or if you decided to use "Fixed"

DoCmd.TransferText acExportFixed, "ExportSpecName", "TableName", "C:\myText.txt", True
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37843384
<No Points wanted>
CraigMan,

This is an example of a perfect use of Access automation.
  "The company's payroll person spends too much time reminding people to enter their time and I've been tasked with automating the process."
This is an example of a real *Need*, rather than something that just "Looks Cool"...

Can you post the procedure/code/Formula that decides:
    "each employee who has failed to enter time on 1 or more days during the previous 7 days." ?

You are under no obligation to do this, ...I just feel it would increase the value of this thread for other members searching here with a similar issue.

;-)

JeffCoachman
0
 

Author Closing Comment

by:CraigMan
ID: 37931130
Sorry about the delay. Had an emergency come up out of town.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now