Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jun 2001
    Location
    Virginia, USA
    Posts
    127
    Thanks
    0
    Thanked 0 Times in 0 Posts

    SQL Statement for Select All (XP)

    I need to write an SQL statement to filter a report. Here are the details:
    Clients have one to four service lines. Data for each Client, ie Sales, Orders Placed,etc are kept for each Service Line. That data is displayed in a report.

    On a form, the users selects a Client from a combo box and a Service Line from a combo box for that client. A command button (cmd OpenReport) opens the report filtered by Client and Service Line. So far so good.

    I need the user to be able to open the report without selecting a service line and get ALL Service Lines for that client. In fact, I would like the first choice in the Service Line combo box to be "ALL". I seem to remember a post here talking about a Union Query to do just this. Any ideas are always appreciated.

    Thanks,

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: SQL Statement for Select All (XP)

    Why not just leave the Service Line combo box blank and just change the OpenReport criteria accordingly.
    Pat <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: SQL Statement for Select All (XP)

    Is the data for each different service line kept in different tables?
    In that case you would need a union query to pull the info from the four tables.
    The syntax is
    sqlstatement1 Union (sqlstatement2) Union (sqlstatement3) Union ( sqlstatement 4);

    The 4 sql statements need to return the same fields, so if the four tables have different fields you need to rename fields, or add in fields as needed.
    Regards
    John



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •