Creating a variable to change the name of an export file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • fresh

    Creating a variable to change the name of an export file

    I have a database that I periodically export to a text file for a Word mail
    merge. I have a query that finds all of the records with a null export date
    and a query that updates the export date to now().

    I have a macro that runs the first query, uses TransferText to send it to a
    file, then runs the update query. However, the file name in TransferText is
    "hard wired" so whatever was there before gets written over.

    Is there a way to create within the macro an environmental variable for the
    file name based on date/time so that I can keep these export files?





  • Joe Fallon

    #2
    Re: Creating a variable to change the name of an export file

    I would use VBA code.
    The macro may accept something like this:

    MyExportPath = myDir & Format(Now(), "yyyyMMddHHmmss ") & ".txt"
    --
    Joe Fallon
    Access MVP



    "fresh" <fresh99@hotmai l.com> wrote in message
    news:lSUQb.2628 53$0P1.17580@tw ister.nyc.rr.co m...[color=blue]
    > I have a database that I periodically export to a text file for a Word[/color]
    mail[color=blue]
    > merge. I have a query that finds all of the records with a null export[/color]
    date[color=blue]
    > and a query that updates the export date to now().
    >
    > I have a macro that runs the first query, uses TransferText to send it to[/color]
    a[color=blue]
    > file, then runs the update query. However, the file name in TransferText[/color]
    is[color=blue]
    > "hard wired" so whatever was there before gets written over.
    >
    > Is there a way to create within the macro an environmental variable for[/color]
    the[color=blue]
    > file name based on date/time so that I can keep these export files?
    >
    >
    >
    >
    >[/color]


    Comment

    Working...