• Access Macro (2000)

    Author
    Topic
    #368813

    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

    Viewing 0 reply threads
    Author
    Replies
    • #578845

      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.

      • #578865

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

      • #578886

        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!!

        • #578893

          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.

        • #578961

          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.

          • #579030

            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.

            • #579034

              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.

            • #579037

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

    Viewing 0 reply threads
    Reply To: Access Macro (2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: