Weird Bug: “DoCmd.OutputTo acOutputQuery” is delet

2019-04-13 01:18发布

I'm encountering a problem where 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)?

6条回答
手持菜刀,她持情操
2楼-- · 2019-04-13 01:40

even 2007 has this problem, it is happening to me also, but very randomly. Sometimes I can run it many times before the bug happens, other times it happens right away, it's a small database, 29 records, and a tiny query, so it's definitely a bug in access

查看更多
仙女界的扛把子
3楼-- · 2019-04-13 01:46

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.

查看更多
Luminary・发光体
4楼-- · 2019-04-13 01:55

I know it's been awhile since the original post, but I have found a solution that I did not see here. I'm using Access 2010. It seems that almost everytime I execute DoCmd.OutputTo acOutputQuery..., my saved query still appears in my list of queries, but the SQL gets wiped out, which subsequently deletes my output file too from the network.

I just reset the SQL before calling DoCmd.OutputTo acOutputQuery...

CurrentDb.QueryDefs("MyQuery").SQL = "SELECT..."

and then call

DoCmd.OutputTo acOutputQuery, "MyQuery"...

So far so good.

查看更多
手持菜刀,她持情操
5楼-- · 2019-04-13 01:55

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.

查看更多
Deceive 欺骗
6楼-- · 2019-04-13 01:55

Another workaround is to change the original query to a make table query, and then use

DoCmd.OutputTo acOutputTable, TableName, ...

It means you have an extra table hanging around, but you could always do a delete table in code or via a query afterwards to clean up.

查看更多
We Are One
7楼-- · 2019-04-13 02:01

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

查看更多
登录 后发表回答