Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2002

    Unanswered: Trouble with format of filename when exporting data as a text file

    I need to programatically create a filename in a specified format when exporting data to a text file. Right now I am using TransferText to export data to a text file when a form is closed.

    Instead of just specifying the filename of where to export the data, is there any way to automatically have the filename be formatted a certain way? For example, always starting with a "T" and then the day of the month followed by the time (in military format). Example of filename if data exported on 4/22/02 at 4:28 pm:
    Please anyone - any suggestions for me?

  2. #2
    Join Date
    Apr 2002

    You certainly have this statment:

    DoCmd.TransferText acExportDelim, "export specification name", "Table name", "Write path, for example c:\my documents\T.txt", False, ""

    Now if you do:

    Dim StringDate as String, NameFile as String
    Dim Path as String
    Dim i as integer
    Dim n as integer

    StringDate = Me!Field_date
    n = Len(StringDate)
    For i = 1 To n
    If Mid(StringDate, i, 1) <> "-" Then
    NameFile = NameFile & Mid(s, i, 1)
    End If
    Next i

    Path = "C:\My Documents\" & NameFile & ".txt"

    Now you replace the file name in the Write path of the statment, with the string variable Path, like this:

    DoCmd.TransferText acExportDelim, "export specification name", "Table name", Path, False, ""

    For having the time in that format it's only add more variables and do another cicle, or instead of having a date only field, have a field that the format date is: Day/Month/Year Hours:Minutes,Seconds, or no field and use the function Date, because function Date has that format.

    Hope to be helpfull!!
    Last edited by Miguel; 04-21-02 at 23:48.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts