Solved

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

Posted on 2012-04-12
3
335 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

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.
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…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

634 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