Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2004
    Posts
    16

    Unanswered: Help with query in access

    Hi

    I have a query which should do the following..

    Bring up all records from customer table that

    datelastvisited field is not during the last 3 months
    or is null
    AND has a region matching a user input value

    OR

    in a customercalls table with a one to many relationship on customerid

    if nextcalldate is within the lst 3 months
    or is null

    i thought i had it working but its not..

    below is the query that i thought was working before I tried adding the null criteria..


    SELECT customers.*, customers.CustomerLastVisitDate, CustomerCalls.CustomerCallDateNext FROM customers INNER JOIN CustomerCalls ON customers.CustomerID = CustomerCalls.CustomerID WHERE ((([customers.customerregion])='" & Me.cboRegion & "') AND ([customers.CustomerLastVisitDate] Not Between Date() And DateAdd('m',-3,Date()))) AND ((CustomerCalls.CustomerCallDateNext) Between Date() And DateAdd('m',-3,Date())) OR (([customercalls.customercalldatenext])=Date());

    can anyone help me?

    I seem to have lsot the plot..

    thanks
    mat

  2. #2
    Join Date
    Sep 2003
    Posts
    228
    I would isolate your problem by making two queries, one for each side of the OR.
    Once you have each of those queries working to your satisfaction, you can just copy and paste the SQL statement together with OR

  3. #3
    Join Date
    Sep 2004
    Posts
    16

    ur a star

    thanks alot that helped and i got in focus!

    cheers again

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    actually this query was answered in another forum three days ago

    http://www.dbforums.com/t1043775.html

    funkube, please do not post the same question in multiple forums, you are wasting a lot of people's time
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Sep 2004
    Posts
    16

    I know!

    I jsut thought id say thanks jsut incase u thought I didnt care!

    mat

Posting Permissions

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