Results 1 to 3 of 3
  1. #1
    IdleJack is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2011
    Location
    Leeds, West Yorkshire England
    Posts
    15

    Filter SQL query by criteria

    Wow my second post and I still need help!



    Working on a customer management dbase and I wrote my first ever SQL query today! The query I wrote is a union query as follows:

    SELECT CustomerAdvisor, Outcome, SoldDate, SoldSameMonth, Product, LeadSource
    FROM [2_AppointMasterSELECT_DRIVEWAYS Query]
    UNION ALL
    SELECT CustomerAdvisor, Outcome, SoldDate, SoldSameMonth, Product, LeadSource
    FROM [2_AppointMasterSELECT_PRODUCTS Query]
    UNION ALL SELECT CustomerAdvisor, Outcome, SoldDate, SoldSameMonth, Product, LeadSource
    FROM [2_AppointMasterSELECT_SOLAR]


    What I am trying to figure out now is how to put in a couple of filter criteria, so as when the query is run it asks for specific criteria, on the following common fields:

    CustomerAdvisor (a single value), SoldDate ('From'-'To' dates)

    Any help is appreciated.

    David

  2. #2
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,071
    Below Each From put the following:

    Where CustomerAdvisor = [pcustomerAdvisor] and Solddate between [startdate] and [enddate]

    When you run the query you should be prompted 3 times for pcustomerAdmisor, startdate and end date.

  3. #3
    IdleJack is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2011
    Location
    Leeds, West Yorkshire England
    Posts
    15
    Quote Originally Posted by RayMilhon View Post
    Below Each From put the following:

    Where CustomerAdvisor = [pcustomerAdvisor] and Solddate between [startdate] and [enddate]

    When you run the query you should be prompted 3 times for pcustomerAdmisor, startdate and end date.
    Hi Ray,

    I entered the above as suggested, modified it a little, but I'm now prompted 3 X for each query that is in the union query; 3 X for each prompt. Below is the modified SQL

    SELECT CustomerAdvisor, Outcome, SoldDate, SoldSameMonth, Product, LeadSource
    FROM [2_AppointMasterSELECT_DRIVEWAYS Query]
    Where CustomerAdvisor = [Enter Customer Advisor] and Solddate between [Start Date dd/mm/yy] and [End Date dd/mm/yy]
    UNION ALL
    SELECT CustomerAdvisor, Outcome, SoldDate, SoldSameMonth, Product, LeadSource
    FROM [2_AppointMasterSELECT_PRODUCTS Query]
    Where CustomerAdvisor = [Enter Customer Advisor] and Solddate between [Start Date dd/mm/yy] and [End Date dd/mm/yy]
    UNION ALL
    SELECT CustomerAdvisor, Outcome, SoldDate, SoldSameMonth, Product, LeadSource
    FROM [2_AppointMasterSELECT_SOLAR]
    Where CustomerAdvisor = [Enter Customer Advisor] and Solddate between [Start Date dd/mm/yy] and [End Date dd/mm/yy]

    Any suggestions as to how I only have to enter the info once?

    Thanks

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

Similar Threads

  1. Apply Filter 2 criteria not applying
    By ahightower in forum Forms
    Replies: 4
    Last Post: 07-28-2011, 03:31 PM
  2. Criteria or Filter Issue
    By MichaelW in forum Queries
    Replies: 1
    Last Post: 07-06-2010, 01:43 PM
  3. Replies: 1
    Last Post: 02-03-2010, 08:17 AM
  4. Inch symbol in query filter criteria
    By sprovoyeur in forum Queries
    Replies: 3
    Last Post: 10-01-2009, 11:24 AM
  5. Criteria or Filter for Query
    By Ryan in forum Queries
    Replies: 1
    Last Post: 08-29-2009, 11:50 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