Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export an access table as a tab delimited text file through VB code???

Status
Not open for further replies.

jbrite

Programmer
Apr 19, 2001
2
0
0
US
I need to Export various access tables from an MDB as tab delimited text files through a Visual Basic program. If you have any suggestions it would be greatly appreciated.

Thanks jbrite(programmer)
jbreitbach@flexsteel.com
 
Try something like the following:

Private Sub Form_Load()
Dim db As DAO.Database
Dim rs As DAO.Recordset
dim i as Integer

i = FreeFile

Set db = OpenDatabase([Database Path])
Set rs = db.OpenRecordset([SQL Query])

Open [Output Filename and Path] For Output As i

Do While Not rs.EOF
Write i, rs.Fields([field1]) & rs.Fields([field2]) & Chr(32)

'Chr(32) inserts a tab into the text file to seperate the
'fields in the recordset

rs.MoveNext
Loop

Close i
rs.Close
db.Close

End Sub
-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
Take a look on the option "Export" with a right on an Access Table, of course, this inside of access
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top