Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2012-04-12
3
Medium Priority
?
343 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 2000 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
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

783 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