Server Filter persistance

G

Gary Shell

I am guessing this has been covered here before, but can't seem to find a
definitive solution in my dejanews searches.

I have an Access ADP app that uses the "DoCmd Openform" construct that
passes a "where clause" to the form being opened. This gets passed, of
course, as a ServerFilter property. If then switch to design view on this
"child form" and make any adjustment, like moving a control and then save
the form, the damn ServerFilter is saved as well, and subsequent invocations
of the form ignore the ServerFilter being passed from the "parent" and
instead use the saved filter.

I have tried setting Me.ServerFilter to '' in the form close event but that
doesn't seem to help.

I have seen some replies from Microsoft that this is a feature. HORSE
HOCKEY. It's is a major pain in the ass. One that requires scanning every
form for a persisted ServerFilter before deployment. I can not think of a
single scenario where I'd want a ServerFilter saved at design time.

How are the rest of you coping with this?

Gary Shell
 
G

Guest

Unfortunately, I'm coping the same way you are...by being
frustrated and embarrassed when I ship out code that
always retrieves the same record every time you open the
form and then having to send out patches within hours.
Back in college, we used to say that when you document a
bug it makes it a feature. Looks like some of the folks
at Microsoft must have graduated in my class! - Dan
 
R

Rodolfo Rughi

just a little work around: before ship my application I execute:

Function scan_forms() As Boolean

Dim mf As AccessObject

For Each mf In Application.CurrentProject.AllForms
DoCmd.OpenForm mf.Name, acDesign
Forms(mf.Name).ServerFilter = ""
DoCmd.Close acForm, mf.Name, acSaveYes
Next mf

End Function
 
D

Dan Goldman

I'm trying a different (I think safer) wokaround, I'd be glad to hear any
comments:

in the form's RecordSource I put an input parameter placeholder, e.g.:
select * from Orders where order_code=?

I set the form's Input Parameters to:
GetOpenArgs()

I have the following code in a module:

Public Function GetOpenArgs()
GetOpenArgs = Forms(CurrentObjectName).OpenArgs
End Function

To open the form, I use the OpenArgs argument, e.g. instead of:
docmd.OpenForm "order",,,"order_code=2"
I use:
docmd.OpenForm "order",,,,,,2

Dan.
 
D

Dan Goldman

I'm trying a different (I think safer) wokaround, I'd be glad to hear any
comments:

in the form's RecordSource I put an input parameter placeholder, e.g.:
select * from Orders where order_code=?

I set the form's Input Parameters to:
GetOpenArgs()

I have the following code in a module:

Public Function GetOpenArgs()
GetOpenArgs = Forms(CurrentObjectName).OpenArgs
End Function

To open the form, I use the OpenArgs argument, e.g. instead of:
docmd.OpenForm "order",,,"order_code=2"
I use:
docmd.OpenForm "order",,,,,,2

Dan.
 
D

Dan Goldman

Public Function GetOpenArgs()
GetOpenArgs = Forms(CurrentObjectName).OpenArgs

Oops, CurrentObjectName isn't supposed to work here (it only worked by
coincidence because I had the form selected in the database window).
I wonder if I can trust the form that's being opened to always be the last
in the Forms collection (it seems to be), and use:
GetOpenArgs = Forms(Forms.Count-1).OpenArgs
or I could change the function to:
Public Function GetOpenArgs(strFormName)
GetOpenArgs = Forms(strFormName).OpenArgs
End Function
and set the forms Input Parameters to include the form name, e.g.:
GetOpenArgs("order")

Dan.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top