Rabu, 03 Oktober 2012

[MS_AccessPros] Re: Clearing filter not working

 

Hi Clint,

When I press the Print button the code saves the form's filter to a public variable which is then used as the WHERE condition for the form opening. It works when the form and therefore report are filtered, but does not work when the form's filter is set to "" per the code in the last message.

thanks!
Connie

Private Sub cmdPrint_Click()
On Error GoTo Proc_Err

'Close the rtrackingspreadsheet report if open
If IsRptOpen("rTrackingSpreadsheet") = True Then
DoCmd.Close acReport, "rTrackingSpreadsheet"
End If

'Remember the filter for the form so it can be used with the report
PubstrF = Me.Filter

DoCmd.OpenReport "rTrackingSpreadsheet", acViewPreview, , PubstrF
PubstrF = ""

--- In MS_Access_Professionals@yahoogroups.com, "Clive" <zctek@...> wrote:
>
> Hi Connie,
>
> What are you using as the source for the Report?
> That should have it's own filter, if any.
> When you change the filter for the Form it will
> not modify the Forms source.
>
> Regards, Clive.
>
> --- In MS_Access_Professionals@yahoogroups.com, mrsgoudge <no_reply@> wrote:
> >
> > Hi All! Long time no see because you've equipped me so I've been solving my problems!!! Thank you!
> >
> > I have a clear button with code below that is supposed to clear the controls on a continuous form and set the filter to "". When this continuous form is filtered and then reset using this button it appears to work and shows all the records. But when I press the Print button, the records that show up on the report are still filtered with the old filter.
> >
> > When I step put a stop in the code and step through it, at the end Me.Filter = "" when I hover over it and when I use the Immediate window and type ?Me.Filter the result is nothing. But the Filter in Data tab of the Properties Sheet still shows the old filter and the FilterOnLoad is No.
> >
> > So even though it appears when stepping through the code that Me.Filter has been reset to "", the Properties Sheet still shows the old filter.
> >
> > Crazy! But I'm guessing you'll shed light on this :-)
> >
> > Thanks!
> > Connie
> >
> >
> > Private Sub cmdReset_Click()
> > On Error GoTo Proc_Err
> > 'Purpose: Clear all the search boxes in the Form Header, and show all records again.
> > Dim ctl As Control
> >
> > 'Clear all the controls in the Form Header section.
> > For Each ctl In Me.Section(acHeader).Controls
> > Select Case ctl.ControlType
> > Case acTextBox, acComboBox
> > ctl.Value = Null
> > Case acCheckBox
> > ctl.Value = False
> > Case acListBox
> > If (ctl.MultiSelect = 0) Then
> > ' Values of the multiselect property:
> > ' 0 � None
> > ' 1 � Simple
> > ' 2 � Extended
> > ctl.Value = Null
> > Else
> > ctl.RowSource = ctl.RowSource
> > ' Found in TheAceMan1's faq, thanx
> > End If
> > End Select
> > Next
> >
> > ' If a filter currently applied,
> > If Me.Filter = "" Or Me.Filter = Null Then
> > If Me.OrderByOn = False Then Me.OrderByOn = True
> > Me.OrderBy = "ActivityDate, TrackingActID"
> > Exit Sub
> > Else:
> > ' Remove the old filter
> > Me.Filter = ""
> > Me.FilterOn = False
> > End If
> >
>

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar