Moderate: Requires basic macro, coding, and interoperability
skills.
This article applies to a Microsoft Access database (.mdb) and to a
Microsoft Access project (.adp).
RESOLUTION
There are two possible workarounds to this behavior.
Method 1
Use the
ServerFilter property instead of
IsFilterOn to apply a filter when the page opens. The following sample code
shows you how to set the
ServerFilter property in the DataPageComplete event.
IMPORTANT: When you create VBScript blocks for MSODSC events, you must add
a parameter to the event name as follows:
<SCRIPT LANGUAGE=vbscript FOR=MSODSC EVENT=Current(oEventInfo)>
The <I>oEventInfo</I> parameter returns specific
information about the event to the script. You must add this parameter, whether
or not it will be used, because the script will not work without
it.
<SCRIPT language=vbscript event=DataPageComplete(oEventInfo) for=MSODSC>
' Set the ServerFilter property to a filter criteria string.
If MSODSC.RecordsetDefs(0).ServerFilter = "" then
MSODSC.RecordsetDefs(0).ServerFilter = "Country = 'UK'"
end if
</SCRIPT>
Method 2
Use a different event, such as the Click event of a button, to
set the
IsFilterOn property. The following sample code toggles the value of the
IsFilterOn property on or off.
<SCRIPT language=vbscript event=onclick for=cmdToggleFilter>
<!--
' Set the Filter criteria.
MSODSC.DataPages(0).Filter = "Country = 'UK'"
If MSODSC.DataPages(0).IsFilterOn then
' If the filter is on, turn it off.
MSODSC.DataPages(0).IsFilterOn = false
else
' Otherwise, turn it back on.
MSODSC.DataPages(0).IsFilterOn = true
end if
-->
</SCRIPT>