Solved

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

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Create a EXCEL FIle from Access Procedure 1 14
deduplicating based on criteria 2 21
trying to catch ODBC error when database opens 2 27
Filter a form 8 13
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

776 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