How can I export a table into a delimited ASCII file? 
Author Message
 How can I export a table into a delimited ASCII file?

I am using VB5,SP3 with an Access 97 database.  I want to programatically
export one table to a delimited ASCII file within VB.  How can I do this?


ThanX in Response.

CBM



Sat, 21 Sep 2002 03:00:00 GMT  
 How can I export a table into a delimited ASCII file?

Quote:

> I am using VB5,SP3 with an Access 97 database.  I want to programatically
> export one table to a delimited ASCII file within VB.  How can I do this?

  Popular question!  Reposting same thing I posted here yesterday:
  Export an Access table to a text file?  Smith has got ya covered with
his excellent resource: http://www.smithvoice.com/vb5expt.htm

--
Jim in Cleveland
If you're writing to me, in my address
change "REAL_Address.see.below" to "worldnet.att.net"
 ((("What's so funny 'bout peace, love & understanding?" - Nick Lowe)))



Sat, 21 Sep 2002 03:00:00 GMT  
 How can I export a table into a delimited ASCII file?

Quote:

> I am using VB5,SP3 with an Access 97 database.  I want to programatically
> export one table to a delimited ASCII file within VB.  How can I do this?

You should use DAO Library.

Define Workspace, Database and recordset.
At Form Load or Activate or Resize Event, create a Workspace, OpenDatabase,
Openrecordset(SQL Select * from Table)
Open an ASCII Text file with specific path.
Do a loop until recordset EOF.
In each loop, assign each Recordset!Field to the TextFileType.Element
Write a line with the TextFileType then Recordset.MoveNext.
At the end of the loop, close the recordset and ASCII file.

You need to define a Type for the output Text file with a delimiter.

--
Posted via CNET Help.com
http://www.help.com/



Sat, 21 Sep 2002 03:00:00 GMT  
 How can I export a table into a delimited ASCII file?



Quote:

> > I am using VB5,SP3 with an Access 97 database.  I want to
programatically
> > export one table to a delimited ASCII file within VB.  How can I do
this?

>   Popular question!  Reposting same thing I posted here yesterday:
>   Export an Access table to a text file?  Smith has got ya covered with
> his excellent resource: http://www.smithvoice.com/vb5expt.htm

> --
> Jim in Cleveland
> If you're writing to me, in my address
> change "REAL_Address.see.below" to "worldnet.att.net"
>  ((("What's so funny 'bout peace, love & understanding?" - Nick Lowe)))

Maybe I'm missing something, but the code example given on this site is very
misleading.....I am still completely lost on how to achieve this?

CBM



Sat, 21 Sep 2002 03:00:00 GMT  
 How can I export a table into a delimited ASCII file?

Quote:
> I am using VB5,SP3 with an Access 97 database.  I want to programatically
> export one table to a delimited ASCII file within VB.  How can I do this?

With VB5 you should use Microsoft DAO 3.5 Object Library in
your Project References.
In the following code, you should have a Database in "C:\temp\db1.mdb"
In this database, there is "Table1" that has fields: ID, Info1 as strings
and a Date field, a Long Integer field, and a Double field.
At run time, user clicks the form, and after few seconds, the output file
is written with the coma as the delimiter.

The Open as Output and the Write statements will do the rest.
Copy and paste the following code to your experimental project:

Option Explicit
' Click the Project menu, select References
' Scroll down and select "Microsoft DAO 3.5 Object Library"
Dim WrkSpc As Workspace
Dim DBase As Database
Dim RecSet As Recordset
Dim strSQL As String  '  SQL command

' Output Fields
Dim TID As String
Dim TInfo As String
Dim TDate As Date
Dim TLong As Long
Dim TDouble As Double

Private Sub Form_Click()
Dim RecNum As Long
strSQL = "Select * from Table1"

On Error GoTo AnyError

Set WrkSpc = CreateWorkspace("", "admin", "")
Set DBase = WrkSpc.OpenDatabase("C:\temp\db1.mdb")
Set RecSet = DBase.OpenRecordset(strSQL)

RecSet.MoveFirst
Open ("C:\temp\TxtFle1.Txt") For Output As #1
RecNum = 0
While Not RecSet.EOF
    RecNum = RecNum + 1
    TID = RecSet!RecID
    TInfo = RecSet!RecInfo1
    TDate = RecSet!RecDate
    TLong = RecSet!RecLong
    TDouble = RecSet!RecDouble
    Write #1, ID, Info, TDate, TLong, TDouble
    RecSet.MoveNext
Wend
RecSet.Close
Close #1
MsgBox CStr(RecNum) & " records are written", _
    vbInformation, "Your name here"
Exit Sub

AnyError:
MsgBox Err.Description, vbCritical, "Your name"

End Sub

--
Posted via CNET Help.com
http://www.help.com/



Sat, 21 Sep 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Best way to export table to delimited text files

2. Export Dataset Table to comma delimited file

3. Howto export tables in text delimited files ?

4. Export Access Table to Delimited Text File

5. Export of a Table to a Ascii-File

6. open mdb file and create several tab delimited ascii files

7. Generating ASCII delimited file from user data entry

8. Help with ASCII Text delimited files

9. Importing an ASCII delimited file

10. ascii file delimited

11. Sequential File Editing Functions (comma-delimited ASCII data)

12. Using ADO to read a comma delimited ASCII text file

 

 
Powered by phpBB® Forum Software