Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / July 2007

Tip: Looking for answers? Try searching our database.

Help building a filter on a form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
RBear3 - 10 Jul 2007 14:25 GMT
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?

Signature

Thanks!!

RBear3
.

SteveS - 12 Jul 2007 08:16 GMT
> 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
[quoted text clipped - 3 lines]
> 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
Signature

Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)

> Okay, I downloaded the Issue database template and simplified it greatly.
>
[quoted text clipped - 48 lines]
>
> Any suggestions?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.