Re: access crashing after filter



It isn't so much a case of not understanding as not knowing you are using
SQL server and an ADO recordset. Maybe I should have known that from the
code, but I didn't. It seems you are saying that tRst.Filter = "my filter"
results in the recordset tRst being redefined as a filtered recordset, so
that in the line Set Me.Recordset = tRst, Me.Recordset is now the filtered
recordset without specifically applying the filter.
My comments about error handling still apply. If you use error handling in
the procedure (or maybe set the code to break on all errors) you should be
able to find out what error is causing the crash. If the code isn't
reaching your Debug.Print line, why not try putting a Debug.Print line
elsewhere, such as before the line that is causing the crash to see if tRst
is what you expect?

<riyaz.mansoor@xxxxxxxxx> wrote in message
news:1178682565.412583.38690@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On May 8, 4:36 pm, "BruceM" <bam...@xxxxxxxxxxxxxxxxx> wrote:
For one thing, -1 is True and 0 is False, assuming that B_Completed,
B_Waived, and B_Loss are Yes/No fields.

I have tried with "=0", "<>0", "=TRUE", "=FALSE". All fail

Perhaps you have left out some code, but you don't seem to have declared
tRst.

Declared at the form module level

One line of code is: Set tRst = Me.Recordset
Later, there is: Set Me.Recordset = tRst
In between, nothing affects either Me.Recordset or tRst. You define tRst
as
Me.Recordset, then you define Me.Recordset as tRst, but to what end? The
filter and the recordset are two different things. Nothing in your
posted
code affects the recordset. If you do have occasion to define
Me.Recordset,
you can just use:

With regrads to above and below comments - I think you've
misunderstood. I'm using ADO recordsets generated from MS SQL Server
instance. MS Access cannot filter such Recordsets in the normal way -
ie using the form properties .Filter and .FilterOn

To filter such a Recordset - the recordset itself has to be filtered
and then re- set to the forms recordset. Just applying the filter on
the ADO recordset will not do. Hence:
Set tRst= Me.Recordset
tRst.Filter = "my filter" ' not enough to filter the form
Set Me.Recordset = tRst ' set the filtered recordset for the form

However, IF there is another way to do this, i'm very interested to
know :)


Me.Recordset = strRS (where strRS is a string that you use as a SELECT
statement). What is the intention of the Recordset code?
It may be helpful to set the code to break on all errors. If the code
does
not reach the debug line, try adding debug lines elsewhere. For one
thing,
make sure that tRst is what you expect (assuming you need it at all).
When I apply a filter I use:
Me.Filter = fil
Me.FilterOn = True
I am not quite familiar with the approach you have taken, but I expect
that
you specifically need to apply the filter, not just define it.

On another note, Value is the default property for a combo box, so there
is
no need to specify:
If cmbFilter = "None"
There is no harm to specifying Value, but you may as well simplify where
you
can.

MS Access is giving me so much trouble!

Riyaz



.



Relevant Pages

  • Re: access crashing after filter
    ... there is: Set Me.Recordset = tRst ... filter and the recordset are two different things. ... MS Access cannot filter such Recordsets in the normal way - ... no need to specify: ...
    (microsoft.public.access.forms)
  • Re: Help with Microsoft help on linking Access to Outlook
    ... in the criteria cell in the graphical query builder. ... use as the source in the routine. ... the same filtered recordset every time. ... choose themselves what fields to filter on. ...
    (microsoft.public.access.formscoding)
  • Re: Help with Microsoft help on linking Access to Outlook
    ... should build the SQL, using a query, then paste it into your code. ... the same filtered recordset every time. ... choose themselves what fields to filter on. ... Set MyRS = MyDB.OpenRecordset" ...
    (microsoft.public.access.formscoding)
  • Re: Help with Microsoft help on linking Access to Outlook
    ... and have the query point to the combo box to get its value. ... the same filtered recordset every time. ... choose themselves what fields to filter on. ... Set MyRS = MyDB.OpenRecordset" ...
    (microsoft.public.access.formscoding)
  • RE: "too few parameters expected" when filtering OpenRecordset
    ... the filter line doesn't look right. ... The only solution I know of is to add a column in the query to get the ... into a second recordset and then assign the second recordset to the listbox. ... 'Define the SQL to run the stored proc ...
    (microsoft.public.access.modulesdaovba)