Results 1 to 4 of 4
  1. #1
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544

    Question Multi-Filter Query

    I have a form where a user enters three search criteria (or less if they like). When they are finished a sub-form displays the results. I want to give the user the option to export those results into Excel. I am trying to get a query to display results based on the user's search criteria. I need to write a SQL statement that will filter (on the query) based on the text box value if the user has entered a criteria. Otherwise I want to display all for that field. I have included my attempt below, but this doesn't work.



    Code:
    SELECT VEND_GARN.EntityType AS [Entity Type], VEND_GARN.TP_SSN AS [TP SSN], VEND_GARN.AcctID AS [Account ID], VEND_GARN.TPName AS [TP Name], VEND_GARN.AcctType AS [Acount Type], VEND_GARN.BegPd AS [Period Begin], VEND_GARN.EndPd AS [Period End], VEND_GARN.TaxDue AS Tax, VEND_GARN.PenDue AS Penalty, VEND_GARN.IntDue AS Interest, VEND_GARN.TotDue AS [Total Liab], VEND_GARN.ReqGarnAmt AS [Garn Amount], AgencyFID.EntityName AS [Agency Name], VEND_GARN.FileDate AS [Garnish Date], VEND_GARN.FunctCode AS [Function Code], VEND_GARN.BudgetCode AS [Budget Code], VEND_GARN.FundCode AS [Fund Code]
    FROM VEND_GARN INNER JOIN AgencyFID ON VEND_GARN.AgencyFID = AgencyFID.EntityFID
    WHERE (((VEND_GARN.FunctCode)=IIf([Forms]![frmVGLookup]![txtFunctCode]<>"",[Forms]![frmVGLookup]![txtFunctCode],[FunctCode])) AND ((VEND_GARN.BudgetCode)=IIf([Forms]![frmVGLookup]![txtBudgetCode]<>"",[Forms]![frmVGLookup]![txtBudgetCode],[BudgetCode])) AND ((VEND_GARN.FundCode)=IIf([Forms]![frmVGLookup]![txtFundCode]<>"",[Forms]![frmVGLookup]![txtFundCode],[FundCode])));
    Thanks for your help in advance.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    So simple! Thank you.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    No problemo!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Multi-Query List Box Combinations?
    By BizIntelGuy in forum Access
    Replies: 3
    Last Post: 07-20-2010, 03:20 PM
  2. Append Query - Multi-Valued Field
    By catat in forum Queries
    Replies: 0
    Last Post: 05-11-2010, 01:52 PM
  3. How to Query a Multi Value Combo Box
    By Viperpurple in forum Queries
    Replies: 0
    Last Post: 03-22-2010, 07:33 AM
  4. Query filter statement
    By Brian62 in forum Access
    Replies: 1
    Last Post: 02-16-2010, 02:34 PM
  5. Replies: 1
    Last Post: 03-01-2009, 09:53 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