Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    Alhassani is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    53
    The query is working in the sample database. When I try to switch to design view this is the error message I get "Microsoft Access can’t represent the join expression Archive_AuditDb.[PCH: Sponsor SSN] = Audit_Defect_Codes_Audit_1.AuditCode in Design view." I keep checking over it, but everything appears to be spelled correctly.

  2. #17
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    you're linking the field [PCH: Sponsor SSN] on the table Archive_AuditDB to the field AuditCode in the table Audit_Defect_Codes_Audit_1. Are you sure this link is correct, look at the join linking your ARCHIVE_AUDITDB to AUDIT_DEFECT_CODES_AUDIT_1 I suspect one of those fields either doesn't exist or isn't spelled correctly.

  3. #18
    Alhassani is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    53
    Ok, I have toned down this query to only pull 1 field for now. Once this one field is solved, I'll add in all the rest.

    Code:
    SELECT Archive_AuditDb.Week, Archive_AuditDb.RMs, SUM(iif(Audit_Defect_Codes_Audit1)![passemployee]=-1,1,0)/COUNT([DCN]) AS Audit1pct
    FROM (Archive_AuditDb LEFT JOIN Audit_Defect_Codes AS Audit_Defect_Codes.Audit1 ON Archive_AuditDb.[PCH: Sponsor SSN] = Audit_Defect_Code_Audit1.Auditcode)
    GROUP BY Archive_AuditDb.Week, Archive_AuditDb.RMs;
    On the final pieces of both the SELECT and FROM clauses, the links are different. The SELECT clause creates "Audit1pct" while the FROM clause creates "Auditcode". These are both created into the Audit1 table. Since this is the temptable being created by the query, I cannot look at the structure of the table for editing. I'm not sure if this is where the error is. The code above tells me that the error is in the FROM clause. I have tried making "Audit1pct" the reference for both the SELECT and FROM clauses. It didn't work.

    This is linked almost exactly as you built it originally. I changed only what needed to be which was tblcodes to Audit_Defect_Codes and Audit_Field_1 to PCH: Sponsor SSN. Banging my head against a wall here. I'm starting to think this is coming down to missing parenthesis.

  4. #19
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    why are you creating a temp table? the queries I gave you do not include a temp table. Just your raw data and a link to a table that includes your codes (which you said you already had). There should be no need to include a temp table at all and without seeing your exact tables (structure) I don't know that I can do any better than I have. All three of my queries are single queries with no temp tables.

  5. #20
    Alhassani is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    53
    I interpreted "Audit_Defect_Code_Audit1" as a temp table. Is this incorrect?

    If so, then that may be the problem.

  6. #21
    Alhassani is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    53
    Turned out to be typos all around. Formula works great now in the main database. The typos are bolded below.

    SELECT Archive_AuditDb.Week, Archive_AuditDb.RMs, SUM(IIf([Audit_Defect_Codes_Audit1]![passemployee]=-1,1,0))/Count([dcn]) AS Audit1Pct
    FROM (Archive_AuditDb LEFT JOIN Audit_Defect_Codes AS Audit_Defect_Codes_Audit1 ON Archive_AuditDb.[PCH: Sponsor SSN] = Audit_Defect_Codes_Audit1.defectcode)
    GROUP BY Archive_AuditDb.Week, Archive_AuditDb.RMs;

  7. #22
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    So you problem is solved then?

  8. #23
    Alhassani is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    53
    Yes, I finished up all of the employee queries last night and am working on the project queries now. I have ran into one thing that I can't explain for the life of me though.

    I have one query that works perfectly fine, no popups when ran. When I copy that query and run, it pops up and asks for the field value. But, I didn't change anything. It is the exact same SQL statement down to the digit. I can work around it, but it is a little bit a of head scratcher.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. limit query results to last 30 days
    By btappan in forum Access
    Replies: 2
    Last Post: 12-12-2013, 02:56 PM
  2. Limit query to one record
    By sotssax in forum Queries
    Replies: 3
    Last Post: 07-28-2011, 01:50 PM
  3. Query to Limit Combo Box Choices
    By jimrockford in forum Queries
    Replies: 2
    Last Post: 04-23-2011, 10:24 PM
  4. Limit Query Results
    By ocampod in forum Queries
    Replies: 5
    Last Post: 01-07-2011, 10:47 AM
  5. Excel Query Limit
    By Afliege in forum Queries
    Replies: 0
    Last Post: 03-19-2010, 10:20 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