Results 1 to 13 of 13
  1. #1
    vector39 is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    May 2017
    Posts
    76

    Search bar no longer filtering list box on form

    Hi everyone, as some of you may know I've been working on a search criteria for a list box that filters based on what the user types into the search bar or using a date range criteria. While I finally got the date range to work (thanks to you guys ) now the search bar won't filter the list box as the user begins typing as it previously was. There is a button where users can add in new info (e.g. a new company, their address, insurance info, etc) and even though it updates on the company table, nothing shows up on the list box. Do list boxes have a limit of rows they display? Here's the following SQL row source for the list box and I suspect the problem is here, particularly in the WHERE clause.

    SELECT tblCompany.CompanyName, tblAssociation.Associate, tblCompany.AAEndDate, tblCompany.ISExpiry, tblCompany.ISDeclaration, tblCompany.Address, tblCompany.City, tblCompany.Province, tblCompany.PostalCode, tblCompany.ContactName, tblCompany.ContactEmail, tblCompany.ContactPhoneNumber, tblPrograms.Program
    FROM tblPrograms INNER JOIN (tblAssociation INNER JOIN tblCompany ON tblAssociation.ID = tblCompany.[Associate(s)].Value) ON tblPrograms.ID = tblCompany.Programs.Value
    WHERE (((tblCompany.AAEndDate) Between Forms!frmMain!txtFrom And Forms!frmMain!txtTo) OR ((tblCompany.ISExpiry) Between forms!frmMain!txtFrom And forms!frmMain!txtTo) And ((tblCompany.CompanyName & tblAssociation.Associate & tblCompany.AAEndDate & tblCompany.ISExpiry) Like "*" & forms!frmMain!SrchTxt & "*"))


    ORDER BY tblCompany.CompanyName;

    AAEndDate and ISExpiry are the two date columns in the list box. If you guys wouldn't mind having a look at this and maybe highlight any potential errors, that would be much appreciated!

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Code:
    WHERE (((tblCompany.AAEndDate) Between Forms!frmMain!txtFrom And Forms!frmMain!txtTo) OR ((tblCompany.ISExpiry) Between forms!frmMain!txtFrom And forms!frmMain!txtTo) And ((tblCompany.CompanyName & tblAssociation.Associate & tblCompany.AAEndDate & tblCompany.ISExpiry) Like "*" & forms!frmMain!SrchTxt & "*"))

    You aren't actually putting a value where the red text is?


    Something more like:

    Code:
    Between #"Forms!frmMain!txtFrom " & "# And #" & Forms!frmMain!txtTo & "#)"
    so the code pulls in the values you need

    Ive assumed the txtfrom and txtto are text fields showing a date.

  3. #3
    vector39 is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    May 2017
    Posts
    76
    Here's the change I made

    Code:
    WHERE (((tblCompany.AAEndDate) Between #"Forms!frmMain!txtFrom " & "# And #" & Forms!frmMain!txtTo & "#)" OR ((tblCompany.ISExpiry) Between #"forms!frmMain!txtFrom " & "# And #" & forms!frmMain!txtTo &"#)" And ((tblCompany.CompanyName & tblAssociation.Associate) Like "*" & forms!frmMain!SrchTxt & "*"))
    There's a missing operator somewhere as I keep getting this error

    And yes, txtFrom and txtTo are text fields showing the date

  4. #4
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Must be & after " to link strings together

  5. #5
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Vector I've just realised your in designer view in a query. Sorry mate. My efforts won't help.

  6. #6
    vector39 is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    May 2017
    Posts
    76
    No worries. I should have specified. I will keep playing with it in SQL view

  7. #7
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Can you put a pic of the design view on here?

  8. #8
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Missing ampersands and had 2 extra quotes.
    See if this gets you closer:
    Code:
    WHERE (((tblCompany.AAEndDate) Between #" & Forms!frmMain!txtFrom  & "# And #" & Forms!frmMain!txtTo & "#)" OR ((tblCompany.ISExpiry) Between #" & forms!frmMain!txtFrom  & "# And #" & forms!frmMain!txtTo & "#)" And ((tblCompany.CompanyName & tblAssociation.Associate) Like "*" & forms!frmMain!SrchTxt & "*"))

  9. #9
    vector39 is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    May 2017
    Posts
    76
    Hi there, I tried the following code

    Code:
    (((tblCompany.AAEndDate) Between #" & Forms!frmMain!txtFrom  & "# And #" & Forms!frmMain!txtTo & "#)" OR ((tblCompany.ISExpiry) Between #" & forms!frmMain!txtFrom  & "# And #" & forms!frmMain!txtTo & "#)
    But I keep getting the same syntax error (missing operator) error. And in particular this part of the code is highlighted

    " OR ((tblCompany.ISExpiry) Between #"


    ​Any feedback is much appreciated!

  10. #10
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    what formats of dates are actually in the txtbox?

  11. #11
    vector39 is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    May 2017
    Posts
    76
    They're set as Short Date (6/19/1999)

  12. #12
    vector39 is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    May 2017
    Posts
    76
    Hi guys here's a pic of the SQL in design view. Not sure if this helps but I figured I'd include it. As it currently stands, there is no more syntax error and the date range text boxes filter between dates as intended however, the search bar no longer filters as the user types.
    Attached Thumbnails Attached Thumbnails access.jpg  

  13. #13
    vector39 is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    May 2017
    Posts
    76
    Never mind guys I got it (with the help of Microsoft Community) working by adding a confirm button which the on click event handler to Me.lstSearchResults.Requery and declaring parameters for the date/time to prevent values being confused as arithmetic vs dates entered. Thank so much!

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

Similar Threads

  1. Search Form similar to the app List style
    By HR123 in forum Database Design
    Replies: 1
    Last Post: 01-31-2016, 11:37 AM
  2. Replies: 1
    Last Post: 09-04-2013, 03:24 PM
  3. Replies: 3
    Last Post: 09-02-2013, 04:33 PM
  4. list form filtering from 1 combo box
    By cooper in forum Forms
    Replies: 5
    Last Post: 08-18-2011, 05:32 PM
  5. Search form with list boxes
    By scottay in forum Programming
    Replies: 15
    Last Post: 07-27-2010, 09:28 AM

Tags for this Thread

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