473,484 Members | 1,667 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to export table data into text file using VB6

15 New Member
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 20257
Hemant Pathak
92 Recognized Expert New Member
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
kalaimurali
1 New Member
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
14705
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
33431
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
8011
by: nologin | last post by:
Is it possible to export data exposed by DataView to Excel file for example ? Seba
3
3928
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
37167
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
7777
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
9752
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
7671
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
7124
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
7103
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6811
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7209
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...
0
5403
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4841
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4527
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3044
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1355
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
588
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.