views:

144

answers:

1

Does anyone know how to export an Access table ("Active Table" in the scenario below) to a .txt file with the Column Headings?

The scenario is below:

Swithcboard Functions: 1. Users add rows or edits rows. 2. The users will click on "View Selected Day", and enter the Day e.g.3 (In the background, the View Macro runs and query filters for Active persons with an Effective day of 3; and read only results are displayed) 3. The users will click on "Export Selected Day" (In the background, the Query replaces the value in "Active Table", with the results for the chosen Effective Day in step 2. The Export Macro then exports the results from Active Table into a .txt file on the desktop)

The query is built as follows: "EmployeeName:left([Employee Name] & Space(22),22)", "Employee ID", "RT #", "A/C #: Format([A/C Number],"000000000000")", "Amount$: Format$([Amount],"000000.00")", "Effective Day" with criteria "[Please enter Effective Day]", "Status" with criteria "Active"

ANy will will be greatly appreciated Thanks Brandy

+1  A: 

Have you considered TransferText?

Syntax (remove line break)

DoCmd.TransferText [transfertype][, specificationname], 
  tablename, filename[, hasfieldnames][, HTMLtablename][, codepage]
Remou
Thank you for your resopnse.I used the Access GUI interface to create my macro, and selected TransferText. As such my text file is exported to my desktop. But it doesnt export with the column names. Im not to good with code, so i am not sure where to put the code you just gave or how to apply it to my scenario? Can you provide any further assistance please?
Brandy
The above is for coding in VBA. Did you set Has Field Names to Yes in your macro?
Remou
The "Has Field Names" is set to No in the macro
Brandy
If you want field names in the text file, you must set it to Yes.
Remou