Results 1 to 9 of 9
  1. #1
    dhicks19 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2012
    Posts
    17

    Multiple Query Criterea and text boxes- If one is blank, no query result

    Hi, I have a form which is fed by a query. The query gets info from tblworders, the query has multiple criteria that is specified in the text boxes on the form.



    Wodate - From and to date
    Department
    Week
    Year
    job type
    status

    All of the above are specified in the form, my problem is if I just want to filter by date (or filter by only one and leave the other text boxes blank there are no results returned even though there should be.

    On the query design, if I delete all of the criteria other than the wodate, it will filter by date and return result but as soon as I put in the other criteria it will not bring anything through.

    Any reason for this, I thought a query could be filtered by multiple criteria

    Thanks

    Heres the sql code:

    SELECT TblWOrders.WONum, TblWOrders.WODate, TblWOrders.CompBy, TblWOrders.WOtime, TblWOrders.department, TblWOrders.description, TblWOrders.site, TblWOrders.type, TblWOrders.Reason, TblWOrders.person, TblWOrders.JobType, TblWOrders.status, TblWOrders.Signoff, TblWOrders.SOdate, TblWOrders.SOtime, TblWOrders.SOcomments, TblWOrders.week, TblWOrders.pyear, TblWOrders.assetcattop, TblWOrders.risk, TblWOrders.tracker, TblWOrders.ResponsiblePerson, TblWOrders.printed, TblWOrders.plannedmaintadded, TblAssets.Desc
    FROM TblAssets INNER JOIN TblWOrders ON TblAssets.AssetNum = TblWOrders.description
    WHERE (((TblWOrders.WODate) Between [FROM DATE] And [TO DATE]) AND ((TblWOrders.department)=[forms]![frmwostatusfilter].[department]) AND ((TblWOrders.JobType)=[forms]![frmwostatusfilter].[jobtype]) AND ((TblWOrders.status)=[forms]![frmwostatusfilter].[status]) AND ((TblWOrders.week)=[forms]![frmwostatusfilter].[wweek]) AND ((TblWOrders.pyear)=[forms]![frmwostatusfilter].[wyear]));

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529

  3. #3
    dhicks19 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2012
    Posts
    17
    Quote Originally Posted by alansidman View Post

    Thanks for reply, I have had a look at that video and he is basically doing what I am doing. He has multiple criteria, but he is using "like" which I dont need to use. Other than that I cant really see what else he is doing differently?

  4. #4
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    He is using like to allow him to use the wildcard "*" which gives you more flexibility. If you don't have all your search boxes entered with data, then without the wildcard, you will continue to bomb out. Currently your SQL is telling Access to look in the search box and if there is nothing there, it will return nothing.

  5. #5
    dhicks19 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2012
    Posts
    17
    Quote Originally Posted by alansidman View Post
    He is using like to allow him to use the wildcard "*" which gives you more flexibility. If you don't have all your search boxes entered with data, then without the wildcard, you will continue to bomb out. Currently your SQL is telling Access to look in the search box and if there is nothing there, it will return nothing.
    Ah i see, so if i use wild card * it should be ok? Do I need to use wild card on all of the criterias?

    Thanks for your help

  6. #6
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Yes. Just like Mike Alexander did in the video.

  7. #7
    dhicks19 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2012
    Posts
    17
    Quote Originally Posted by alansidman View Post
    Yes. Just like Mike Alexander did in the video.
    I did what he did in the video and still having the exact same issue, if i have more than the date criteria it wont filter on date at all. However the other criteria work fine and filters on them, it just wont filter the date unless the date is the only criteria even with the wildcard and like statement.

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  9. #9
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Time to post a copy of your db with some sample data so we can diagnose it. Dummy up any confidential data. Run a compact and repair. Save as an .mdb file to reach the broadest audience and then upload.

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

Similar Threads

  1. Replies: 9
    Last Post: 06-04-2014, 10:45 AM
  2. Replies: 1
    Last Post: 09-28-2011, 09:48 PM
  3. Replies: 17
    Last Post: 08-19-2011, 01:19 PM
  4. Query Criterea
    By 0000 in forum Queries
    Replies: 2
    Last Post: 05-06-2011, 09:50 PM
  5. Controls go blank on empty query result
    By kevdfisch in forum Programming
    Replies: 4
    Last Post: 08-25-2009, 08:07 AM

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