Results 1 to 3 of 3
  1. #1
    data808 is offline Noob
    Windows 8 Access 2007
    Join Date
    Aug 2012
    Posts
    727

    Filter Not Working

    I have a form I will call FORM1 with a bunch of unbound text boxes. The control source is to a query that has this expression in the criteria row for certain fields:

    Like "*" & [Forms]![FORM1].[txtPermit] & "*"
    Like "*" & [Forms]![FORM1].[txtName] & "*"
    Like "*" & [Forms]![FORM1].[txtDate] & "*"

    In the unbound text boxes whatever I type will give me a filter that has a wild card at the beginning or end of the data I enter. After I finish typing this data, I have a filter button that will take me to the next form that I will call FORM2. FORM2 is also set to the same query as FORM1. FORM2 is a split form that will filter out data based on what I typed in FORM1. However, the problem I am having is that the filter does not show null fields for the unbound text boxes from FORM1. Example:

    FORM1 has these unbound text boxes:

    txtPermit
    txtName
    txtDate

    If I type "John" for the txtName field and click the filter button to open, it will show all the records that have the name John in it except for the records that are null for the txtPermit or txtDate. I would still want these records to show up regardless if they are null or not. As long as "John" is in the record, I want it to show no matter what. Do I have to change the expression in the query for that to happen?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Test all controls for a possible filter, if not used, skip it...

    Code:
    If not isnull(cboState) then  sWhere = sWhere & " and [state] like '*" & cboState & "*'"
    If not IsNull(txtName) then   sWhere = sWhere & " and [Name] like '*" & txtName & "*'"
    If not IsNull(txtContact) then  sWhere = sWhere & " and [Contact]  like '*" & txtContact.value & "*'"
    
    'remove 1st And
    sWhere= mid(sWhere,4)
    
    sSql = "SELECT * FROM tblArchitectureFirms WHERE "
    sSql = sSql & sWhere

  3. #3
    data808 is offline Noob
    Windows 8 Access 2007
    Join Date
    Aug 2012
    Posts
    727
    Don't really understand your code. Right now the only records that show in FORM2 have to have all 3 of the fields filled out. (txtPermit, txtName, and txtDate) I do have a total of 10 fields but because I do not have an expression such as this:
    Like "*" & [Forms]![FORM1].[txtPermit] & "*" for the other 7 fields in the query, these 7 fields do not matter if they have data entered into them or not. They will show up in with the filter on. Its just the 3 fields with the expressions in the query and also the ones that have the unbound textboxes in FORM1 that have to have data entered in order for the filter to show these records. I'm thinking the expression is looking for something to be entered in these 3 fields and if nothing is there and the field is null, it skips these records and moves on.

    Can anyone help?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Form filter not working
    By workuser in forum Forms
    Replies: 4
    Last Post: 02-04-2013, 02:48 AM
  2. Filter not working the first time
    By NISMOJim in forum Programming
    Replies: 4
    Last Post: 07-07-2012, 06:38 PM
  3. Macro Filter not working....
    By avarusbrightfyre in forum Access
    Replies: 2
    Last Post: 06-18-2011, 04:09 PM
  4. Filter Not Working
    By BigCat in forum Reports
    Replies: 13
    Last Post: 06-06-2011, 12:48 PM
  5. Filter By Form not working!
    By Freybourne in forum Access
    Replies: 6
    Last Post: 06-22-2010, 09:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums