Help building a filter on a form

R

RBear3

Okay, I downloaded the Issue database template and simplified it greatly.

Now, I can't get the "search issues" form to work.

I have the following controls on my search form:
Application (dropdown list)
TextSearch (text field)


I'd like to modify the existing code so that when I make an entry and click
the "search" button, it will make the form footer visible (where the
"browse_all_issues" form is imbedded as a subform). That part works. But,
the next lines set the filter and turn it on...
Me.FormFooter.Visible = True
DoCmd.MoveSize Height:=Me.WindowHeight + Me.FormFooter.Height

The previous part of my code builds the filter. Here is where I can't get
it to work. How do I tell it to take my "strWhere" and add to it to create
a filter that will do the following:

Only pull up records where the Application is eqaul to my selected
application. AND Pull up records where the Title, Question, OR Answer
include my textsearch entry?

When I try to simply build the application, I get an error (Run-time
error '438': Object doesn't support this property or method) When I debug,
it is highlighting my line that says...
If Nz(Me.Application) <> "" Then


Here is the actual code I have...

Private Sub Search_Click()
Dim strWhere As String

strWhere = "1=1"

' If Category
If Nz(Me.Application) <> "" Then
'Add it to the predicate - exact match
strWhere = strWhere & " AND " & "Issues.Application = '" &
Me.Application & "'"
End If

'DoCmd.OpenForm "Browse Issues", acFormDS, , strWhere, acFormEdit,
acWindowNormal
If Not Me.FormFooter.Visible Then
Me.FormFooter.Visible = True
DoCmd.MoveSize Height:=Me.WindowHeight + Me.FormFooter.Height
End If
Me.Browse_All_Issues.Form.Filter = strWhere
Me.Browse_All_Issues.Form.FilterOn = True




Any suggestions?
 
S

SteveS

When I try to simply build the application, I get an error (Run-time
error '438': Object doesn't support this property or method) When I debug,
it is highlighting my line that says...
If Nz(Me.Application) <> "" Then


You have named an object using a reserved word. Here is a list of reserved
words:


http://www.allenbrowne.com/AppIssueBadWord.html


Find and *use* a naming convention. There are many schemes for naming; here
is one (Google 'naming convention' to find more):

http://www.mvps.org/access/general/gen0012.htm


BTW, don't use spaces (or special characters ie #'%&*) in names either.
Instead of "Browse Issues", use "BrowseIssues" or"Browse_Issues". The users
won't see (or shouldn't see) the objects names!

The previous part of my code builds the filter. Here is where I can't get
it to work. How do I tell it to take my "strWhere" and add to it to create
a filter that will do the following:

Only pull up records where the Application is eqaul to my selected
application. AND Pull up records where the Title, Question, OR Answer
include my textsearch entry?


This is AIR code, but it would look something like:

'---snip---
If Nz(Me.Application) <> "" Then
'Add it to the predicate - exact match
strWhere = strWhere & " AND " & "Issues.Application = '" &
Me.Application & "'"

If Len(Me.TextSearch) > 0 Then
'Title, Question, OR Answer
strWhere = strWhere & " AND (Title Like '*" & Me.TextSearch & "*'"
strWhere = strWhere & " OR Question Like '*" & Me.TextSearch &
"*'"
strWhere = strWhere & " OR Answer Like '*" & Me.TextSearch & "*')"
End If
End If
'---snip---


HTH
 

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