Re: Subform modifies main form's recordsource - Crash!



<hufflehuffle@xxxxxxx> wrote in message
news:1135674151.903633.295830@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> Rob Oldfield schrieb:
>
> > I think you'll need to supply some detail on exactly what your code
looks
> > like.
>
> Okay, here we go. The recordsource for the main form is a query. I go
> through the querydefs and modify the sql statement accordingly. Then in
> the AppyFilter statement of the main form (which always gets fired) I
> set the recordsource to the query.
>
> I had a Me.Parent.Requery in the procedure after the last line, to no
> avail. I tried setting the recordsource to the SQL statement directly
> (opposed to the QueryDef solution) - same problem.
>
> I'll look for the ServicePacks, though.
>
> Thanks!
> Andreas
> ------clip
>
> Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
>
> Dim qd As QueryDef
> Dim qdIndex As Integer
> qdIndex = 0
> For Each qd In CurrentDb.QueryDefs
> If qd.Name = "QRY_TestergebnisseJOINSamplesFilter" Then
> Exit For
> End If
> qdIndex = qdIndex + 1
> Next
>
> If (ApplyType = 1) And (Me.Parent.RecordSource <>
> "QRY_TestergebnisseJOINSamplesFilter") Then
> qd.SQL = "SELECT DISTINCT TblTesteingabe.* FROM TblTesteingabe
> INNER JOIN TblSample ON
> [TblTesteingabe].[ID]=[TblSample].[TestErgebnisseID] WHERE (" &
> Me.Filter & ");"
> End If
> End Sub
>

Not sure what's causing the issue as yet, but a couple of points:

Why loop through the querydefs to grab the one you want? Why not just
use...

set qd=currentdb.querydefs("QRY_TestergebnisseJOINSamplesFilter")

And why the criterion in the If that compares the parent's recordsource to
QRY_TestergebnisseJOINSamplesFilter? Isn't it permanently set as that?

Anyway... some more questions:

How are you actually applying the filter? Through Access's built-in
buttons?
Is it failing just for specific values, or does it sometimes work and
sometimes not for the same filter? (assuming no changes in the underlying
data)
Is the error you're quoting the exact text?
What is the record source of the subform? It's just linked via a standard
parent-child relationship?


.


Quantcast