Re: access crashing after filter
- From: "BruceM" <bamoob@xxxxxxxxxxxxxxxxx>
- Date: Wed, 9 May 2007 07:43:22 -0400
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
.
- Follow-Ups:
- Re: access crashing after filter
- From: riyaz.mansoor@xxxxxxxxx
- Re: access crashing after filter
- References:
- access crashing after filter
- From: riyaz.mansoor@xxxxxxxxx
- Re: access crashing after filter
- From: riyaz.mansoor@xxxxxxxxx
- Re: access crashing after filter
- From: BruceM
- Re: access crashing after filter
- From: riyaz.mansoor@xxxxxxxxx
- access crashing after filter
- Prev by Date: Re: Tab Control Help Please
- Next by Date: Re: I don't WANT the form opened maximized.
- Previous by thread: Re: access crashing after filter
- Next by thread: Re: access crashing after filter
- Index(es):
Relevant Pages
|