G
Guest
I use code to rewrite the Filter property of a Query, and then use acCmdSave
to save that filter.
When I step through the code however, the filter sometimes reverts back to
the previous version after the save command.
For instance:
CurrentDb.QueryDefs(Me.cboReport).Properties("Filter") = cboFilters
DoCmd.RunCommand acCmdSave
Testing the filter property before I run the first line, I'll get:
(StateCode = 'CA')
Then I'll set the filter and double check it in the immediate pane, and I'll
get the string I intended to set:
(StateCode = 'IN')
Then I'll let the save command process, and I'll check it again, and it's
back to the original:
(StateCode = 'CA')
But it doesn't happen all the time! The next time I run the code it keeps
the setting that I gave it. Or not, depending on how it feels.
This is not the only screwy thing I've seen with acCmdSave. Sometimes I will
get random errors completely unrelated to anything going on or anything in
question. For instance, I've gotten "Can't find the function or macro 'Forms'
referred to in your expression" when there isn't anything I've changed that
includes the "Forms" keyword. But I know that it is a bug (or seems to be a
bug) because you can just hit F5 to pick up the code where you left off, and
it does not regenerate that error.
All in all, some screwy things going on with acCmdSave, and it doesn't
appear to be corruption. I've tried it in different db's. Has anyone else
seen this, or can they point me at information regarding it?
to save that filter.
When I step through the code however, the filter sometimes reverts back to
the previous version after the save command.
For instance:
CurrentDb.QueryDefs(Me.cboReport).Properties("Filter") = cboFilters
DoCmd.RunCommand acCmdSave
Testing the filter property before I run the first line, I'll get:
(StateCode = 'CA')
Then I'll set the filter and double check it in the immediate pane, and I'll
get the string I intended to set:
(StateCode = 'IN')
Then I'll let the save command process, and I'll check it again, and it's
back to the original:
(StateCode = 'CA')
But it doesn't happen all the time! The next time I run the code it keeps
the setting that I gave it. Or not, depending on how it feels.
This is not the only screwy thing I've seen with acCmdSave. Sometimes I will
get random errors completely unrelated to anything going on or anything in
question. For instance, I've gotten "Can't find the function or macro 'Forms'
referred to in your expression" when there isn't anything I've changed that
includes the "Forms" keyword. But I know that it is a bug (or seems to be a
bug) because you can just hit F5 to pick up the code where you left off, and
it does not regenerate that error.
All in all, some screwy things going on with acCmdSave, and it doesn't
appear to be corruption. I've tried it in different db's. Has anyone else
seen this, or can they point me at information regarding it?