Solved

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

Posted on 2012-04-12
3
334 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
[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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) 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

Technology Partners: 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

Suggested Solutions

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

734 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