By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,398 Members | 1,362 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,398 IT Pros & Developers. It's quick & easy.

Regarding DoCmd.TransferText

P: 1
Hello,
I'm using Access 2002-2003. My application exports an Access table into a text file and then appends the text file with several othet files to generate a final file XXXX.ftm .

Issue:
One of the field in my access table has a type TEXT and length 255. I enter a string value "OMSI-2" which is 6 char long.
Via two steps this field end up in NLNVM.FTM and there it becomes 8 char long (the string OMSI-2 + 2 spaces).

the two steps are:

1. function Exportone (in VB) exports data from table ocsda to ocsda.txt

2. appends ocsda.txt + other files to nlnvm.ftm

Function ExportOne(strTbl As String, strDir As String, strExt As String) As Boolean
On Error GoTo ExportOneErr

DoCmd.TransferText A_EXPORTFIXED, strTbl, strTbl, strDir + "\" + strTbl + strExt
ExportOne = True

ExportOneExit:
Exit Function
ExportOneErr:
Debug.Print Error$
gsaddtolog "ERROR: Export " & strTbl & " mislukt!", gfGetConfigItem("LOG", "DirFile"), gfGetConfigItem("LOG", Err.Description)
ExportOne = False
Resume ExportOneExit
End Function

I'm not able to find why is this happens. Is this is something to do with this textTransferType "A_EXPORTFIXED". Plz help me. Thanking You
Feb 15 '08 #1
Share this Question
Share on Google+
1 Reply


Expert Mod 2.5K+
P: 2,545
Hello,
I'm using Access 2002-2003. My application exports an Access table into a text file and then appends the text file with several othet files to generate a final file XXXX.ftm .

Issue:
One of the field in my access table has a type TEXT and length 255. I enter a string value "OMSI-2" which is 6 char long.
Via two steps this field end up in NLNVM.FTM and there it becomes 8 char long (the string OMSI-2 + 2 spaces).

the two steps are:

1. function Exportone (in VB) exports data from table ocsda to ocsda.txt

2. appends ocsda.txt + other files to nlnvm.ftm

Function ExportOne(strTbl As String, strDir As String, strExt As String) As Boolean
On Error GoTo ExportOneErr

DoCmd.TransferText A_EXPORTFIXED, strTbl, strTbl, strDir + "\" + strTbl + strExt
ExportOne = True

ExportOneExit:
Exit Function
ExportOneErr:
Debug.Print Error$
gsaddtolog "ERROR: Export " & strTbl & " mislukt!", gfGetConfigItem("LOG", "DirFile"), gfGetConfigItem("LOG", Err.Description)
ExportOne = False
Resume ExportOneExit
End Function

I'm not able to find why is this happens. Is this is something to do with this textTransferType "A_EXPORTFIXED". Plz help me. Thanking You
Hi. TransferText is indeed being told to export in fixed width, as you thought. It is really for importing or exporting structured text files that represent records where field boundaries are either delimited (comma-speparated or similar) or fixed-width. Couldn't easily determine where one field ends and the next begins otherwise.

When you read your text field back from the finished file you can always lose the extra spaces by using the RTrim function to remove them automatically. It would avoid rewiting your export routine.

RTrim is very simple to use - instead of referring to the field itself, refer to RTrim([field]).

Regards

Stewart
Feb 15 '08 #2

Post your reply

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