473,548 Members | 2,704 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Export table to TXT file using 2 methods

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 vba is a
little confusing for me since i have never used it plus i have lost
touch with vb coding since last 8 monhts.

anywayz, my problem is i'm trying to export a table that's modified by
me which is taken from a file at a prompt, now i have to export the
same file in the same format it came in Fixed and Delimited formats. I
can do this easily using the DoCmd.TransferT ext acExportDelim, "ORDER
Export Specification", "TBL0219", "C:\Test.tx t" . All i do is change
the acExport to Fixed.

The file being imported has fixed width properties. It has 2 types of
records M(main set of record i.e Cust name, ph, email etc) and S(if the
operator upsold items it adds these records w/ corresponding field).
Once it is modified it now has just main record all M's. Now exporting
this format is easy but due to constraints i have to have the new
database output to the same format it used to be in which mean i have
to check now which one of the fields now has additional upsale items
i.e added QTY and PartNo.

Any ideas on how i can work this?

Example
1. Raw input file looks like

MTea 20050218 James Connor 1 1 1 3005 2003
4003 etc
MBag 20050219 Joanne Smith 1 1 1 3005 2003
4003 etc
S 1 3009

2. After my modification it looks like

MTea 20050218 James Connor 1 1 1 3005 2003
4003 etc
MBag 20050219 Joanne Smith 1 1 1 3005 2003
4003 etc 1 3009

3. Output needs to look like raw data again

Any help will be apprecaited

thanks Neil

Nov 13 '05 #1
10 14715
Neil wrote:
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 vba is a
little confusing for me since i have never used it plus i have lost
touch with vb coding since last 8 monhts.

anywayz, my problem is i'm trying to export a table that's modified by
me which is taken from a file at a prompt, now i have to export the
same file in the same format it came in Fixed and Delimited formats. I
can do this easily using the DoCmd.TransferT ext acExportDelim, "ORDER
Export Specification", "TBL0219", "C:\Test.tx t" . All i do is change
the acExport to Fixed.

The file being imported has fixed width properties. It has 2 types of
records M(main set of record i.e Cust name, ph, email etc) and S(if the
operator upsold items it adds these records w/ corresponding field).
Once it is modified it now has just main record all M's. Now exporting
this format is easy but due to constraints i have to have the new
database output to the same format it used to be in which mean i have
to check now which one of the fields now has additional upsale items
i.e added QTY and PartNo.

Any ideas on how i can work this?

Example
1. Raw input file looks like

MTea 20050218 James Connor 1 1 1 3005 2003
4003 etc
MBag 20050219 Joanne Smith 1 1 1 3005 2003
4003 etc
S 1 3009

2. After my modification it looks like

MTea 20050218 James Connor 1 1 1 3005 2003
4003 etc
MBag 20050219 Joanne Smith 1 1 1 3005 2003
4003 etc 1 3009

3. Output needs to look like raw data again


Why don't you use the same import/export specification to export the
query/table data to a text file?

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)
Nov 13 '05 #2
> Why don't you use the same import/export specification to export the
query/table data to a text file?

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)


Well it would be easier if my import were the same specification as
export. See when i import it does not have the extra fields that add
once i manipulate the file. That's the whole point i'm importing it so
i can read the file and make it the way i want it. I cannot add those
fields in advance coz unfortunately the data file comes in such way and
the reason we export the same way is coz its gonna go to a diff place
where it may be read the same way or not. That system is setup to
accept the same way our systems are. So unless we change all the
systems which could be expensive or time consuming, i have to import it
the way it is change it keep that Table and export it the way it came
in.

Nov 13 '05 #3
This is a sample code my cousin helped me with, can someone help me
fill the rest!

Function TextExport_Fixe d()
Dim rs As DAO.Recordset
Dim strFix As String
Dim strSRecord As String
Dim strPad
Set rs = CurrentDb.OpenR ecordset(tblnam e)

Do While Not rs.EOF
For i = 0 To rs.Fields.Count - 1
If Left(rs.Fields( i).Name, 3) = "QTY" Then

Else

End If
strPad = Space(rs.Fields (i).FieldSize - Len(rs(i)))
strFix = strFix & rs(i) & strPad
Next

strFix = strFix & vbCrLf

rs.MoveNext
Loop
rs.Close
Call WriteToFile
End Function

Nov 13 '05 #4
Can anyone help me finish the rest of this code my cousin help me put
together

Function TextExport_Fixe d(Content As String, Filepath As String)
'DoCmd.Transfer Text acExportFixed, "LIVEOPS ORDER FIXED Export
Specification", "OVEN0219", "C:\Test2.t xt"
Dim rs As DAO.Recordset
Dim strFix As String
Dim strSRecord As String
Dim strPad
Set rs = CurrentDb.OpenR ecordset(tblnam e)

Do While Not rs.EOF
For i = 0 To rs.Fields.Count - 1
If Left(rs.Fields( i).Name, 3) = "QTY" Then
Content =
Else

End If
strPad = Space(rs.Fields (i).FieldSize - Len(rs(i)))
strFix = strFix & rs(i) & strPad
Next

strFix = strFix & vbCrLf

rs.MoveNext
Loop
rs.Close

Call WriteToFile
End Function
Public Function WriteToFile(Con tent As String, Filepath As String,
Optional Append As Boolean = False) _
As Boolean
'If Append = true, then content will be appended to existing file
contents
'else existing file is overwritten
'Returns: True if Successful, false otherwise
Dim iFile As Integer

iFile = FreeFile
If Append Then
Open Filepath For Append As #iFile
Else
Open Filepath For Output As #iFile
End If

Print #iFile, Content
SaveToFile = True

ErrorHandler:
Close #iFile
End Function

Nov 13 '05 #5
Neil wrote:
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 vba is a
little confusing for me since i have never used it plus i have lost
touch with vb coding since last 8 monhts.

anywayz, my problem is i'm trying to export a table that's modified by
me which is taken from a file at a prompt, now i have to export the
same file in the same format it came in Fixed and Delimited formats. I
can do this easily using the DoCmd.TransferT ext acExportDelim, "ORDER
Export Specification", "TBL0219", "C:\Test.tx t" . All i do is change
the acExport to Fixed.

The file being imported has fixed width properties. It has 2 types of
records M(main set of record i.e Cust name, ph, email etc) and S(if the
operator upsold items it adds these records w/ corresponding field).
Once it is modified it now has just main record all M's. Now exporting
this format is easy but due to constraints i have to have the new
database output to the same format it used to be in which mean i have
to check now which one of the fields now has additional upsale items
i.e added QTY and PartNo.

Any ideas on how i can work this?

Example
1. Raw input file looks like

MTea 20050218 James Connor 1 1 1 3005 2003
4003 etc
MBag 20050219 Joanne Smith 1 1 1 3005 2003
4003 etc
S 1 3009

2. After my modification it looks like

MTea 20050218 James Connor 1 1 1 3005 2003
4003 etc
MBag 20050219 Joanne Smith 1 1 1 3005 2003
4003 etc 1 3009

3. Output needs to look like raw data again


Why don't you use the same import/export specification to export the
query/table data to a text file?

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)
Nov 13 '05 #6
> Why don't you use the same import/export specification to export the
query/table data to a text file?

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)


Well it would be easier if my import were the same specification as
export. See when i import it does not have the extra fields that add
once i manipulate the file. That's the whole point i'm importing it so
i can read the file and make it the way i want it. I cannot add those
fields in advance coz unfortunately the data file comes in such way and
the reason we export the same way is coz its gonna go to a diff place
where it may be read the same way or not. That system is setup to
accept the same way our systems are. So unless we change all the
systems which could be expensive or time consuming, i have to import it
the way it is change it keep that Table and export it the way it came
in.

Nov 13 '05 #7
This is a sample code my cousin helped me with, can someone help me
fill the rest!

Function TextExport_Fixe d()
Dim rs As DAO.Recordset
Dim strFix As String
Dim strSRecord As String
Dim strPad
Set rs = CurrentDb.OpenR ecordset(tblnam e)

Do While Not rs.EOF
For i = 0 To rs.Fields.Count - 1
If Left(rs.Fields( i).Name, 3) = "QTY" Then

Else

End If
strPad = Space(rs.Fields (i).FieldSize - Len(rs(i)))
strFix = strFix & rs(i) & strPad
Next

strFix = strFix & vbCrLf

rs.MoveNext
Loop
rs.Close
Call WriteToFile
End Function

Nov 13 '05 #8
Can anyone help me finish the rest of this code my cousin help me put
together

Function TextExport_Fixe d(Content As String, Filepath As String)
'DoCmd.Transfer Text acExportFixed, "LIVEOPS ORDER FIXED Export
Specification", "OVEN0219", "C:\Test2.t xt"
Dim rs As DAO.Recordset
Dim strFix As String
Dim strSRecord As String
Dim strPad
Set rs = CurrentDb.OpenR ecordset(tblnam e)

Do While Not rs.EOF
For i = 0 To rs.Fields.Count - 1
If Left(rs.Fields( i).Name, 3) = "QTY" Then
Content =
Else

End If
strPad = Space(rs.Fields (i).FieldSize - Len(rs(i)))
strFix = strFix & rs(i) & strPad
Next

strFix = strFix & vbCrLf

rs.MoveNext
Loop
rs.Close

Call WriteToFile
End Function
Public Function WriteToFile(Con tent As String, Filepath As String,
Optional Append As Boolean = False) _
As Boolean
'If Append = true, then content will be appended to existing file
contents
'else existing file is overwritten
'Returns: True if Successful, false otherwise
Dim iFile As Integer

iFile = FreeFile
If Append Then
Open Filepath For Append As #iFile
Else
Open Filepath For Output As #iFile
End If

Print #iFile, Content
SaveToFile = True

ErrorHandler:
Close #iFile
End Function

Nov 13 '05 #9
Can anyon tell me why i am getting a Run-Time Error 3259: Invalid Field
Data Type for the following line:

strPad = Space(rs.Fields (i).FieldSize) - Len(rs(i))

All i'm trying to do is find the padding i need for the fixed width,
and add it to the string when i output the string to my file.

Nov 13 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5013
by: Matt | last post by:
I have an ASP page that calls ASP routines that I created that execute a database query and return the results to a recordset. I then iterate through the recordset and display the data in a table. Before I iterate through the recordset I instruct the browser that the content type is Excel using the following line: (Response.ContentType =...
0
443
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 vba is a little confusing for me since i have never used it plus i have lost touch with vb coding since last 8 monhts. anywayz, my problem is i'm...
3
3033
by: excyauseme | last post by:
Hi guys! Do you know what is the best way to export a text file, this one is a log file that is already comma delimited thru a module run by my access database, to an excel spreadsheet? I need to do this thru the module, and I don't see how I can export a txt file from access without loading it to a temp table first. I've checked out the...
3
3937
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 to get an exported text file of about 400 MB instead 16 MB which is the normal size of that data. By examining this file with a text editor I found...
17
7202
by: Fabry | last post by:
Hi All, I'm new of this group and I do not know if this is the correct group for my question. I have a DLL with its export library (.lib) wrote in Borland C++ 6. In borland everything is OK and I am able to include the lib and use the class that i have exported creating an instance with new etc... I would like to export this class in...
9
7685
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 is 8 characters long. This field needs to be exported as pic(15) padded in the front with 0's (zeros). The next field an ID name that is 15...
5
16324
by: bhodgins | last post by:
Hi, I am new on here, and had a newbie question that I am stumped with. I am not new to access, but am new to VB. I am trying to export BLOBs from a field called photo to external jpeg files. I have tried the MS kb 210486 and successfully got the import/export to work with a sample table, but only the first record. I do not wish to impost...
3
4550
by: Edward Reid | last post by:
OK, I've been watching my DB grow and have known for a long time I would have to move the back end, but of course I waited until I started getting odd behavior (at about 1.92GB). So today I installed MySQL and (after a bit too much time getting the data source working) started exporting tables. I successfully exported eight of my nine tables,...
8
18746
by: iheartvba | last post by:
Hi I am using Access 2007 and am trying to export a query to a fixed length text file. I tried using the following code to export the text file: DoCmd.TransferText acExportFixed, , "qryFFRDeFile", "C:\qryFFRDeFile.txt", True Access asks for a specification name, now here lies the challenge, how do I create an export specification I have...
0
7711
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7954
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7467
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6039
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5085
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3497
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3478
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1054
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
755
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.