Results 1 to 9 of 9
  1. #1
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Access Macro (2000)

    I have a very simple macro which I'm performing the OutputTo Action to output to a RTF format. My question is... I have to include a name in the Output File like so...D:/Reports/bms.rtf I'd like to somehow instead of naming the file, just add the system date. Is this possible. Or is there a command afterwards that I can rename the file to display the date. I'm running a batch file to run the macro. Any help would be much appreciated!! Thanks beforehand

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access Macro (2000)

    Put this code in a module.
    Replace the name of the report with yours, and change the the date format to what you want.

    Sub OutputToRtf()
    DoCmd.OutputTo acOutputReport, "MyReport", acFormatRTF, "D:Reportsbms" & Format(Date, "yymmdd") & ".rtf"
    End Sub

    In the Macro, replace the Outputto action by RunCode and enter OutputToRtf in the function name box.
    Francois

  3. #3
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access Macro (2000)

    This will be the first time I create a module. Do I need to save it as something specific? Thanks so much!!

  4. #4
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access Macro (2000)

    I've read your post thoroughly and have trippled check my work. I'm getting a stubborn error as follows when I run the macro...
    Microsoft Access can't find the name "OutputToRtf" you entered in the expression.

    You may have specified a control that wasn't on the current object w/o specifying the correct form or report context.

    But it works when I run the module code from the design view. Any ideas? Thanks a million!!

  5. #5
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access Macro (2000)

    Sorry, I forgot to add the parenthese after OutputToRtf() in the macro.
    Make also that the module have not the same name as the sub.
    Francois

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Access Macro (2000)

    Macros can't call Subs only Functions. You'll have to change the routine to a public function before you can call it from a macro.
    Charlotte

  7. #7
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access Macro (2000)

    How can I go about doing this. Here is what I have up to this point...

    The error:
    The expression you entered has a function name that Microsoft Access can't find.

    In my Macro in which I named BMS, I have RunCode as my Action and OutputToRtf() as my function name.

    In my Module in which I named Module1, I have the following code:

    Sub OutputToRtf()
    DoCmd.OutputTo acOutputReport, "Budget Summary Report", acFormatRTF, "D:Reportsbms" & Format(Date, "yyyymmdd") & ".rtf"
    End Sub

    Thanks again to everyone for helping me with this problem.

  8. #8
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access Macro (2000)

    Change the code to :
    Function OutputToRtf()
    DoCmd.OutputTo acOutputReport, "Budget Summary Report", acFormatRTF, "D:Reportsbms" & Format(Date, "yyyymmdd") & ".rtf"
    End Function

    Sory, about that, but if it is your first code, I never use macro's and wasn't aware if this subtlety.
    Francois

  9. #9
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access Macro (2000)

    Thanks so much. Everything worked like a charm!!!

Posting Permissions

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