Wednesday, April 6, 2011

Weird Bug: "DoCmd.OutputTo acOutputQuery" is deleting the query

Has anybody encountered this problem that DoCmd.OutputTo acOutputQuery deletes the query itself, the second time it is run? Is there any workaround/patch for this bug (at least seems like a bug to me)?

Is there a better way to do this?

From stackoverflow
  • I think the behaviour you described "...deletes the query itself, the second time it is run" occurs when the query returns no records.

    Varun Mahajan : I tested this after you shown me this possibility, but it does not seem to be the case. In fact this time, I ran it twice and it worked. Very weird.
  • I could not recreate your error, even with a query that returned 0 records. Maybe your file was corrupt?

    Are you including the objectname, Outputformat, and Output file in your code? Yor example did not include them.

    Varun Mahajan : I did include objectname, Outputformat, and Output file in code. Most probable reason seems to be that the file is corrupt.
  • Re: your comment.

    Did you do a file copy, or did you copy the objects between two databases? IF the second, you might want to try doing a compact and repair on a file-copy of the original.

    You might even want to try that on the real original.

    Varun Mahajan : I did not copy anything between databases.
  • Hi,

    this also happening to me also right now.

    you were able to fix this ?

    cheers Alex

    David-W-Fenton : Have you patched your Access installation to have the latest service packs?
  • Hi, it happens to me too. I'm using Access 2003.

    The only workaround I've found is to preserve a copy of the original mdb, this way I can restore the mdb when it happens.

    It seems that Access 2007 doesn't have this problem.

0 comments:

Post a Comment