Results 1 to 3 of 3
  1. #1
    goodguy is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Dec 2010
    Location
    Zanzibar, Tanzania
    Posts
    229

    Filter on fields in two tables

    I am trying to build a query to pull active records from Table1 filtered on the foreign key for active records in Table2 as below:


    Code:
     SELECT SALARIES.SALARYID, SALARIES.STAFFID, SALARIES.BASICPAY, SALARIES.ALLOWANCEPAY, SALARIES.OVERTIMEPAY, SALARIES.OTHERPAY, FROM SALARIES INNER JOIN STAFF ON SALARIES.STAFFID = STAFF.STAFFID WHERE STAFF.ACTIVE = TRUE AND SALARIES.ACTIVE = TRUE

    The result is a blank recordset as long as the filter on STAFF.ACTIVE is included. Deleting the offending filter results in a populated recordset.

    How can I enforce both filters whilst extracting records from one table only?

  2. #2
    Join Date
    Apr 2017
    Posts
    1,679
    1. The comma after ...SALARIES.OTHERPAY is abyndant! (Probably a typo - otherwise the query would return an error!);
    2. Either all values in field STAFF.ACTIVE for persons which have active salaries are FALSE, or values in this field aren't boolean! Include field STAFF.ACTIVE into SELECT clause and remove condition STAFF.ACTIVE = TRUE, run the query, and look at result! What you get in added column?
    (Or instead
    STAFF.ACTIVE include an expression STAFF.ACTIVE = TRUE. Do you get TRUE or FALSE for this expression when the query is run?)

  3. #3
    goodguy is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Dec 2010
    Location
    Zanzibar, Tanzania
    Posts
    229
    Thank you and sorry. I fixed a syntax typo, and the query now runs fine.

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

Similar Threads

  1. Replies: 1
    Last Post: 04-12-2017, 07:39 AM
  2. Trying to filter with two fields
    By Ruegen in forum Forms
    Replies: 1
    Last Post: 07-15-2014, 11:52 PM
  3. Look Up Tables and Filter Results
    By starkeymd in forum Access
    Replies: 1
    Last Post: 01-12-2012, 04:17 PM
  4. Filter on one or more fields using a dialog box
    By jparker1954 in forum Reports
    Replies: 21
    Last Post: 07-15-2011, 03:39 PM
  5. Filter By Date In Different Fields
    By Douglasrac in forum Queries
    Replies: 13
    Last Post: 03-21-2011, 05:24 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