?
Solved

how to export from microsoft access 2010 to txt (tab delimited)

Posted on 2013-01-15
5
Medium Priority
?
2,531 Views
Last Modified: 2013-01-16
hi

i asked this question yesterday, and i get an answer, and i accepted, and i closed the question; but i have still difficult so i will ask the question again;
i will show you exact what i need, and i hope that someone will be able help with this.

i attached a file called finance.txt,  and this file contained data that i make  manually, and i need to can make file exact like with vba.

so i attached an access database with a table that called table1 and in this table has the same data like in the finance.txt file and the database have a form with a command button "export" but it's not have any code behind that.
 
so i need a vba code (to the export button) to make that it's will export the data on the table "table1" to a file that will seems exact like the finance.txt file

thanks a lot
finance.txt
sample.mdb
0
Comment
Question by:bill201
[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
  • 2
  • 2
5 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 1000 total points
ID: 38779466
place this codes in the click event of the button

Private Sub Command0_Click()
Dim rs As DAO.Recordset, strRec As String, j As Integer
Set rs = CurrentDb.OpenRecordset("table1")

Open CurrentProject.Path & "\finance.txt" For Append As #1

Do Until rs.EOF
     For j = 1 To rs.Fields.Count - 1
          If strRec = "" Then
          strRec = rs(j) & vbTab
          Else
          strRec = strRec & rs(j) & vbTab
          End If
     Next
     Print #1, strRec
     rs.MoveNext
     strRec = ""
Loop
Close #1
End Sub

basically that will be the codes that you will use

btw, where did the date column in your text file came from

also, what is the text file formatting, is it Fixed width?

please provide the text formatting
0
 

Author Comment

by:bill201
ID: 38779510
thanks a lot for your answer and the code/
honestly i don't know. i think that its not fixed width. i will try to import (in my other software that called finanda) from this file like is it and i hope that is will be a successful....
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 38779525
did you use an export specification to create the text file?

if you did, upload a copy of the db with the export specification..
0
 
LVL 31

Assisted Solution

by:Helen Feddema
Helen Feddema earned 1000 total points
ID: 38780254
You can also use the TransferText method to make either a comma-delimited or fixed width text file.  Here are some examples:

Private Sub cmdExportTextDelimited_Click()

   DoCmd.TransferText transfertype:=acExportDelim, _
      specificationname:="CustomerExportSpecs", _
      tablename:="qryCustomers", _
      FileName:="D:\Documents\Examples\Export Delimited.csv", _
      hasfieldnames:=True

End Sub

Private Sub cmdImportTextDelimited_Click()

   DoCmd.TransferText transfertype:=acImportDelim, _
      tablename:="tblMonthlyData", _
      FileName:="D:\Documents\Examples\Monthly Data.csv", _
      hasfieldnames:=False

End Sub

Open in new window

0
 

Author Comment

by:bill201
ID: 38784970
thanks a lot for you both

sorry that i don't response Up to now, i don't was in town and i was not able to test this code. now the two codes are working perfect
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
This article helps those who get the 0xc004d307 error when trying to rearm (reset the license) Office 2013 in a Virtual Desktop Infrastructure (VDI) and/or those trying to prep the master image for Microsoft Key Management (KMS) activation. (i.e.- C…
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

752 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