Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2004
    Location
    Reading, UK
    Posts
    16

    Unanswered: OutputTo command or action isnt available now

    I have been having some problems with the DoCmd.OutputTo method with Access 2002 and there seem to be users with similar problems and various reasons/fixes available but they are all a bit sketchy. I thought I'd post this to hopefully help anyone else who experiences the same problem.

    I was getting the runtime error 2046 Command or Action 'DoCmd.OutputTo' isn't available now when using the following code:

    DoCmd.OutputTo acOutputForm, sFormName, acFormatXLS, sFileName, (Not bEmail)

    (where sFormName and sFileName are passed from the class module behind the calling form).

    The error seemed to be sporadic at first and some posts mention having the database window hidden on startup may cause this problem. This works but is no good if you want to compile your database and don't want the db window on show.

    I found that a) having the object open and b) using the following code just before you export does the trick without the need to show the database window on startup:

    DoCmd.SelectObject acForm, sFormName

  2. #2
    Join Date
    Apr 2004
    Location
    Reading, UK
    Posts
    16

    Exclamation

    Further to my last message, if you are using DoCmd.OutputTo with dynamic SQL, e.g. you need to export a parameterised stored procedure, you can't open the stored procedure first so you need to create or use a dummy procedure instead. This can then be opened and selected using:

    DoCmd.OpenStoredProcedure csPRC_DUMMY
    DoCmd.SelectObject acStoredProcedure, csPRC_DUMMY

    Before calling:

    DoCmd.OutputTo acOutputStoredProcedure, "EXEC prcTest '1'", acFormatXLS, sFileName, (Not bEmail)

    and finally closing the dummy stored procedure:

    DoCmd.Close acStoredProcedure, csPRC_DUMMY

  3. #3
    Join Date
    May 2010
    Posts
    1
    I noticed that the error occurs when you have a form in pop up mode and the report is on a different mode. By changing the forms to pop up mode = Yes to match the from from where I was executing the "output to" the error went away

Posting Permissions

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