Results 1 to 7 of 7
  1. #1
    mseeker22 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2011
    Posts
    35

    Query filter search

    I have a form used to search through customer records. 'F_Booking Customer Search' (See screenshot) and the query behind it 'Q_Booking Customer Search' (also see screenshot) which filters down customer details based on the more information the user enters into the search fields. When the form first opens it should show all customer records.



    The query is refreshed on every key stroke entered into any of the search boxes, as with the screenshot I've tried to show this . . . 'sh' has been typed in so far and returned all records in the surname column beginning with 'sh', then if the user were to type something into the forename search box that would then further filter the information.

    This works except it only includes fields that have any data in. So if I have a customer that has all fields with data in except say 'Forename' then it won't show that record at all.

    I tried to over come this with this in the query : =IIf(IsNull([Forms]![F_Booking Customer Search].[TxtForename])," ",(Like "*" & [Forms]![F_Booking Customer Search].[TxtForename] & "*"))
    but sadly this just didn't return any records at all.


    I'm having a mental block and can't work out what to do next?


    Help please :-)

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    I don't think the IIF is necessry, and you show a space in the " ". Try just the second argument as criteria: Like "*" & [Forms]![F_Booking Customer Search].[TxtForename] & "*"

    Check this tutorial http://datapigtechnologies.com/flash...earchform.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    mseeker22 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2011
    Posts
    35
    Thats what I had tried but because there are some records without 'Forename' for example it won't show them at all, even when I'm using the 'Surname' field for example.

    The example shown in the video is basically the same as what I have but every field in his database has data in it . . . unfortunately thats not the same for mine. Due to the methods of collection, there will by Mobile phone numbers for one customer and Home phone numbers for another . . . any ideas?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    Not sure, maybe:
    Like "*" & [Forms]![F_Booking Customer Search].[TxtForename] & "*" Or Is Null
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    mseeker22 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2011
    Posts
    35
    Ok, that works! . . . next question :-) . . . how do I get it to sort numbers against blank fields? It is correctly sorting the named fields but for some reason it isn't sorting the numbers see pic >

    I don't mind that it shows the fields without numbers in them, but I do need it to show the fields with the correct/matching data in at the top if that makes sense?

    Thank you

  6. #6
    mseeker22 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2011
    Posts
    35
    Sorry just to clarify, by 'named fields' I was simply referring to fields that hold customers 'Names'

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    I don't know your data well enough. Why does it go Shillings, Shillings, Williams, Thorpe, Shillings, Williams. Which numbers?

    Null will always sort first (or last if Descending). You could use an IIF expression in ORDER BY clause:
    ORDER BY IIf(IsNull(field),"999999999", field)
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Search query HELP
    By sanos_a in forum Forms
    Replies: 2
    Last Post: 04-07-2011, 06:43 AM
  2. ID search Query
    By clarkej in forum Queries
    Replies: 3
    Last Post: 01-25-2011, 08:03 AM
  3. Search Query
    By convey2web in forum Queries
    Replies: 3
    Last Post: 11-08-2010, 02:27 PM
  4. Database Search filter
    By dada in forum Programming
    Replies: 7
    Last Post: 08-19-2010, 12:42 AM
  5. Search with in a Query
    By AccessCodeMonkey in forum Queries
    Replies: 4
    Last Post: 03-09-2010, 03:16 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