473,414 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

How to export table data into text file using VB6

Hi,

By using VB6.0, I want to export database table data into text file with a tab delimiter.

My User interface has:
• Drop down list box contain list of data base table name.

• A path selection area, allowing the user to specify the filename, path and file type for the export. This will incorporate standard Windows functionality for allowing the user to specify file type such as tab delimited text. The path will default to the xyz server upon which my project instance is running but will allow the user to navigate to any other mapped drive.

• Export button – when clicked, this activates the data export using the parameters provided.

I am new to this job..please give me relevant code...

Thanks in advance
Radhakrishnan
vrradhakrishnan@gmail.com
Sep 2 '06 #1
2 20241
Hemant Pathak
92 Expert
I have the following sql statement that I use right now to export a database table into an excel spreadsheet using an automation process. Unfortunantly not all can be exported as excel files and instead need to be exported as a text file with tab delimitations. Can anyone help me change the sql statement I included below to make it instead export to a tab delimited text file. You help is welcomed. Thanks,

Dim DAODB As Database

'EXPORTS TABLE IN ACCESS DATABASE TO EXCEL
Set DAODB = OpenDatabase(strDB)

'If excel file already exists, you can delete it here
If Dir(strExcel) <> "" Then Kill strExcel

DAODB.Execute ("SELECT * INTO [Excel 8.0;DATABASE=" & strExcel & "].[" & _
strWorksheet & "] FROM " & "[" & strTable & "]")
DAODB.Close
Sep 5 '06 #2
hi radhakrishnan,
U try this code this wil work correctly

Set rs = db.OpenRecordset("select * from " & tablelst) ' tablelst-this is yr table name
tmp_val = ""
If Not rs.EOF Then
rs.MoveLast
rcount = rs.RecordCount
rs.MoveFirst
Close
Open App.Path & "\" & tablelst & ".txt" For Output As #1
For i = 0 To rs.Fields.Count - 1
If i < rs.Fields.Count - 1 Then
tmp_val = tmp_val & rs.Fields(i).Name & vbTab
ElseIf i = rs.Fields.Count - 1 Then
tmp_val = tmp_val & rs.Fields(i).Name
End If
Next i
tmp_val = tmp_val & vbCrLf
While Not rs.EOF
For i = 0 To rs.Fields.Count - 1
tmp_val = tmp_val & rs.Fields(rs.Fields(i).Name) & vbTab
Next i
tmp_val = Mid(tmp_val, 1, Len(tmp_val) - 1)
tmp_val = tmp_val & vbCrLf
rs.MoveNext
DoEvents
Label1.Caption = rs.AbsolutePosition & "/" & rcount
Wend
Print #1, tmp_val
End If
MsgBox "Process Completed"

regards,
kalaivani murali...
Jun 28 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Neil | last post by:
Hi guyz, just trying out this google feature so if i post if in the wrong area i appologize. now to my question. BTW i'm new to access programming, i've done a little vb6.0 and vb.net but access...
4
by: Hans [DiaGraphIT] | last post by:
Hi! I want to export a dataset to an excel file. I found following code on the net... ( http://www.codeproject.com/csharp/Export.asp ) Excel.ApplicationClass excel = new ApplicationClass();...
3
by: nologin | last post by:
Is it possible to export data exposed by DataView to Excel file for example ? Seba
3
by: Daniel Wetzler | last post by:
Dear MSSQL- experts, I have a strange problem with SQLSERVER 2000. I tried to export a table of about 40000 lines into a text file using the Enterprise manager export assitant. I was astonished...
5
by: RadhakrishnanR | last post by:
Hi, By using VB6.0, I want to export database table data into (i.e based on the selected file type(xls or txt)) excel file or text file with a tab delimited text file. My User interface has: ...
7
by: Vanessa | last post by:
hi Everyone, I have two questions on exporting data to Excel using ASP (w/o converting formatted excel file into web page and then plug in the dynamic data): 1. Can we export data into...
1
by: smaczylo | last post by:
Hello, I've recently been asked to work with Microsoft Access, and while I feel quite comfortable with Excel, I'm at a complete loss with databases. If someone could help me with this issue I'm...
9
by: NEWSGROUPS | last post by:
I have data in a table in an Access 2000 database that needs to be exported to a formatted text file. For instance, the first field is an account number that is formatted in the table as text and...
3
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I have a question for you. I have a .csv file which has many lines of data. Each line has many data fields which are delimited by ",". Now I need to extract part of data from this...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.