views:

504

answers:

5

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?

+1  A: 

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

Mitch Wheat
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.
Varun Mahajan
A: 

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.

Jeff O
I did include objectname, Outputformat, and Output file in code. Most probable reason seems to be that the file is corrupt.
Varun Mahajan
+1  A: 

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.

CodeSlave
I did not copy anything between databases.
Varun Mahajan
A: 

Hi,

this also happening to me also right now.

you were able to fix this ?

cheers Alex

Alex
Have you patched your Access installation to have the latest service packs?
David-W-Fenton
A: 

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.

Mauro Stangalini