Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 3rd, 2006, 07:58 AM
Registered User
 
Join Date: May 2006
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to format txt file exported from access table

I am starter with access VBA and now have a problem when trying to export access table to txt file. I have an access table called tblCitationList, it has three column:ID,Volume, Issue and Pub date. It looks like:
-----------------------------------------
ID Volumn Issue Pub date
-----------------------------------------
1 113 15 2006
2 76 3 2004
-----------------------------------------

I want to export this table to txt file with the following format:

----------------------------------------------------
ID - 1
VI - 113 [from TblCitationlist "Volume"]
IP - 15 [from TblCitationlist "Issue"]
DP - 2006 [from TblCitationlist "Pub date"]

ID - 2
VI - 76 [from TblCitationlist "Volume"]
IP - 3 [from TblCitationlist "Issue"]
DP - 2004 [from TblCitationlist "Pub date"]
----------------------------------------------------

Could anyone help? Thanks very much!!

Reply With Quote
  #2 (permalink)  
Old August 4th, 2006, 02:16 PM
pjm pjm is offline
Authorized User
 
Join Date: Jul 2006
Location: Boston, MA, USA.
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here's some simple code that should do the trick:

Dim db As Database
Dim rs As Recordset

Dim nRecords As Long, r As Long

    Set db = CurrentDb()
    Set rs = db.OpenRecordset(TableName, dbOpenDynaset)
    Open OutputFilename For Output As #1

    rs.MoveLast
    nRecords = rs.RecordCount
    rs.MoveFirst

    For r = 1 To nRecords

    Print #1, "ID - "; r
    Print #1, "VI - "; rs("Volume")
    Print #1, "IP - "; rs("Issue")
    Print #1, "DP - "; rs("Pub date")

        rs.MoveNext
    Next r

    rs.Close
    db.Close


-Phil-
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
View txt File as DOS Format suresh.cgmohan VB How-To 2 September 27th, 2006 07:40 AM
Import a Comma separated txt file to SQL table arielote C# 2 April 17th, 2006 01:08 AM
Get table records into Txt or CSV format kapi.goel SQL Language 0 April 10th, 2006 01:47 AM
save file in csv, txt format in jsp URGENT ernidhi2003 JSP Basics 1 October 14th, 2004 04:59 PM
Export table to txt in Access XP midtowncreek Access 9 May 24th, 2004 08:02 AM



All times are GMT -4. The time now is 10:08 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.