Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there something screwy with acCmdSave?

Status
Not open for further replies.

rubbernilly

Programmer
Sep 20, 2005
447
US
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 [blue]sometimes[/blue] 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?
 
Why using acCmdSave when the query don't seem to be open in design view ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Doesn't the acCmdSave command bypass the "Do you want to save this object?" message?

If I close the form after I've applied a filter to the subform I get that message. Using acCmdSave was an attempt to get around that.

BTW, I got by my initial problem by splitting the SourceObject setting commands:

Code:
Me.DynamicSub.SourceObject = ""
CurrentDb.QueryDefs(Me.cboReport).Properties("Filter") = cboFilters
Me.DynamicSub.SourceObject = "Query." & Me.cboReport
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top