Results 1 to 10 of 10
  1. #1
    Steven.Allman is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2010
    Posts
    118

    Combine Queries

    I tried this in another thread, but I think I have gone a different route, so I want to start a new question.



    Each record has 4 date fields and an invoice received field.
    I want a query that looks at all 4 date fields, and generates results if ANY of the four are older than 30 days and have not 'invoice received"

    How in the hell would I go about this?

    Am i asking way to much or do I need 28 sub queries of queries etc?

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Are you using the query builder to create your query?

  3. #3
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    generically speaking; if you want any of 4 fields to be/meet the criteria then these are OR statements ...meaning that you put in the criteria at each column but be sure to put them all on a separate line - not on the same line (which creates an AND statement). Query design grid offers all those lines just for this purpose. Should be a snap.

  4. #4
    Steven.Allman is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2010
    Posts
    118
    Query Design, not the wizard..

  5. #5
    Steven.Allman is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2010
    Posts
    118
    i guess that is the trick, NTC. I am doing a <Date()-30 AND [past suspense] = "yes" but also have to have OR record 2 is <Date()-30 AND [past suspense] = "yes" OR record 3 <Date()-30 AND [past suspense] = "yes", etc..
    problem is, its showing multiple records on the same line.
    Its combining my records and I need them kept seperate..
    I kind of need someone to tell me how to start this over.. I am about 30 seconds from deleting all my queries and going it again

  6. #6
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    maybe I'm not understanding the issue correctly, but this seems really simple
    SELECT *
    FROM myTable
    WHERE (date1<date()-30 OR date2<date()-30 OR date3<date()-30 OR date4<date()-30) AND invoiceReceived = "no"

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by TheShabz View Post
    maybe I'm not understanding the issue correctly, but this seems really simple
    SELECT *
    FROM myTable
    WHERE (date1<date()-30 OR date2<date()-30 OR date3<date()-30 OR date4<date()-30) AND invoiceReceived = "no"
    That is *exactly* what the Query Designer would have done if used correctly.

  8. #8
    Steven.Allman is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2010
    Posts
    118
    Ok, took your guys advice. Its a combination of all these items.
    I have an AND statement followed by an OR statement, followed by an AND, followed by an OR, and so on and so forth. Its a much longer statement than I thought it would be, and the results are not what I was hoping for, BUT, i can work with the results quite well. Thanks for your help guys.....

  9. #9
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    if your AND statement is common, then you dont need it after every one. just group together your OR statements with () and put one AND at the end.

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    ...just as Post #6 shows.

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

Similar Threads

  1. Combine 3 Queries
    By Logix in forum Queries
    Replies: 1
    Last Post: 06-10-2010, 06:03 PM
  2. Combine crosstab queries
    By thart21 in forum Queries
    Replies: 3
    Last Post: 05-03-2010, 10:36 AM
  3. Combine queries
    By thart21 in forum Queries
    Replies: 1
    Last Post: 03-05-2010, 01:39 PM
  4. Replies: 1
    Last Post: 05-28-2009, 05:08 AM
  5. Combine queries results in forms
    By frasilvio in forum Queries
    Replies: 12
    Last Post: 01-10-2008, 01:34 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