Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter continous form

Status
Not open for further replies.

Moxy1

Programmer
Aug 29, 2002
75
US
I have a continuous form that is open through a pervious form as follows:
Code:
docmd.openform "frmContinuous",,,"[price]=1.00"

What I'm attempting to do is narrow down the search even further once the continuous form is open. To do this I created a list box on the form heading with the following attached to the After Update event of the list box:

Code:
Private Sub lstDesc_AfterUpdate()
Dim strFilter As String
Dim strDescLike As String
Dim strDesc As String
Dim strDescVal As String
Dim varDescItems As Variant

strFilter = Trim(Me.Filter)

If IsNull(strFilter) = False Or strFilter <> "" Then
strFilter = Me.Filter
strDesc = "'*'"
strDescLike = "Like"  'Default Conditional

For Each varDescItems In Me.lstDesc.ItemsSelected
strDescVal = Me.lstDesc.ItemData(varDescItems)
    If strDesc = "'*'" Then
        strDescLike = "In"
        strDesc = "'" & strDescVal & "'"
    Else
        strDesc = strDesc & ",'" & strDesc & "'"
    End If
Next varDescItems
MsgBox strFilter
strFilter = strFilter & " AND ((qrySelAcknowledge.desc " & strDescLike & "(" & strDesc & "))"
Me.FilterOn = True

Me.Requery
Me.Repaint
Me.Refresh
End If

End Sub

For some reason I can't get this to work. Can anyone see where I may be going astray?

 
put a debug.print strfilter before the me.filteron=true line and post the results

ck1999
 
Not sure about everything but it may be a good ideas to have it say

me.filter = strfilter

before the

me.filteron = true statement

and you are missing one ) at the end of the last strfilter line

so in recap use

Code:
strFilter = strFilter & " AND ((qrySelAcknowledge.desc " & strDescLike & "(" & strDesc & ")))"
me.filter = strfilter 
Me.FilterOn = True



ck1999
 
How are ya Moxy1 . . .

I get the idea of what your doing, but there's a problem in your code.

The following line . . .
Code:
[blue]   strDesc = "'*'"[/blue]
. . . presets [blue]strDesc[/blue] so that . . .
Code:
[blue]   If strDesc = "'*'" Then[/blue]
. . . is [purple]always true![/purple] I hope you see my point!

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Aceman,

Would not the value after the 1st time through the if loop change so strdesc not longer is "'*'". I think he was using this to set the "In" at the beginning of the list.

Or does the * in that string act like a wildcard?

ck1999
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top