filter problem

M

Marco

I disire filter subform with new condition too, where ID = ID+1 OR ID-1.How
can do it ?

now i use:
Dim strFilter As String
strFilter = ""
If Not IsNull(Me.txtE01) Then
strFilter = strFilter & " AND ((E_1=" & Me.txtE01 & ") OR (E_2=" &
Me.txtE01 & ") OR (E_3=" & Me.txtE01 & ") OR (E_4=" & Me.txtE01 & ") OR
(E_5=" & Me.txtE01 & ") OR (E_6=" & Me.txtE01 & ") OR (J=" & Me.txtE01 & ")
OR (S=" & Me.txtE01 & "))"
End If
If Len(strFilter) > 0 Then
strFilter = right(strFilter, Len(strFilter) - 5)
Me!frmtblS_subform1.Form.Filter = strFilter
Me!frmtblS_subform1.Form.FilterOn = True
Else
Me!frmtblS_subform1.Form.FilterOn = False
End If

thx
 
D

Douglas J. Steele

What is ID supposed to be? How is it possible for a value to be equal to
that value plus or minus one?
 
M

Marco

ID is subform id
with filter a search records contiguous
ex if a field have value 10 a search all records have 10 and are the next
ID, ID+1
 
J

J

I am making an assumption at what you want to do (run for your lives!)
and here is what I recommend (Generalized for a wider audience, you'll
have to fill in your specific subform name and variables name):

'Forward
Dim LastID as Long 'Or whatever your ID field variable type is
LastID = Me!ID
Me.FilterOn=False
Me.Recordset.FindFirst "[ID] = " & LastID
DoCmd.GoToRecord acForm, "FORMNAME", acNext, 1
Me.Filter = "[ID]=" & Me!ID
Me.FilterOn = True

'Backwards
Dim LastID as Long 'Or whatever your ID field variable type is
LastID = Me!ID
Me.FilterOn=False
Me.Recordset.FindFirst "[ID] = " & LastID
DoCmd.GoToRecord acForm, "FORMNAME", acPrevious, 1
Me.Filter = "[ID]=" & Me!ID
Me.FilterOn = True

Hope that helps,
~J
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top