Regarding DoCmd.TransferText

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amitk
    New Member
    • Feb 2008
    • 1

    Regarding DoCmd.TransferText

    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(strTb l As String, strDir As String, strExt As String) As Boolean
    On Error GoTo ExportOneErr

    DoCmd.TransferT ext 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 textTransferTyp e "A_EXPORTFIXED" . Plz help me. Thanking You
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    Originally posted by amitk
    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(strTb l As String, strDir As String, strExt As String) As Boolean
    On Error GoTo ExportOneErr

    DoCmd.TransferT ext 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 textTransferTyp e "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

    Comment

    Working...