Results 1 to 3 of 3
  1. #1
    dso808 is offline Novice
    Windows XP Access 2003
    Join Date
    May 2010
    Posts
    6

    Access Takes my Query and Alters it!

    Please help. I have a large query which I develop in Notepad and then paste into the query window for the RecordSource property for a report. However, I've found out that the query gets mangled for some reason. Access seems to ADD and repeat statements in my query. This is what I put in:



    SELECT [Service Request].[SR#], [Service Request].[Project Title], [Service Request].[Proj Category], [Service Request].[FHB Status], [Service Request].[Orig Commitment Date], [Service Request].[Revised Commitment Date], [Service Request].[IMG Contact], [Service Request].[Comments], [Service Request].[Comments2],NZ([Service Request].[Est Hrs - PC/LAN Mand],0) + NZ([Service Request].[Est Hrs - PC/LAN Discret],0) As EstHrs,'PC/LAN' As Dept,[Service Request].[Act Hrs - PC/LAN Mand] As ActHrsMand,[Service Request].[Act Hrs - PC/LAN Discret] As ActHrsDis, [Service Request].[Risk]
    FROM [Service Request] INNER JOIN [Business Owner] ON [Service Request].[Bus Owner] = [Business Owner].[Dept/Div/Group]
    WHERE (([Service Request].[Orig Commitment Date] <> null) OR ([Service Request].[Revised Commitment Date] <> null)) AND ([Service Request].[Copy - PC/LAN]=True) AND ([Service Request].[Proj Category]<>"Annual Production Support") AND ([Service Request].[FHB Status]="Approved" Or [Service Request].[FHB Status]="Implemented" Or [Service Request].[FHB Status]="On-Hold" OR ([FHB Status] = "Completed" AND [Actual Completion Date] >= #7/1/2010#)) AND (isNull([Service Request].[Act Hrs - PC/LAN Mand]) AND isNull([Service Request].[Act Hrs - PC/LAN Discret]))

    And this is what I see when I re-open the query window:

    SELECT [Service Request].[SR#], [Service Request].[Project Title], [Service Request].[Proj Category], [Service Request].[FHB Status], [Service Request].[Orig Commitment Date], [Service Request].[Revised Commitment Date], [Service Request].[IMG Contact], [Service Request].Comments, [Service Request].Comments2, NZ([Service Request].[Est Hrs - PC/LAN Mand],0)+NZ([Service Request].[Est Hrs - PC/LAN Discret],0) AS EstHrs, 'PC/LAN' AS Dept, [Service Request].[Act Hrs - PC/LAN Mand] AS ActHrsMand, [Service Request].[Act Hrs - PC/LAN Discret] AS ActHrsDis, [Service Request].Risk
    FROM [Service Request] INNER JOIN [Business Owner] ON [Service Request].[Bus Owner] = [Business Owner].[Dept/Div/Group]
    WHERE ((([Service Request].[Proj Category])<>"Annual Production Support") AND (([Service Request].[FHB Status])="Approved" Or ([Service Request].[FHB Status])="Implemented" Or ([Service Request].[FHB Status])="On-Hold") AND (([Service Request].[Orig Commitment Date]) Is Not Null) AND (([Service Request].[Copy - PC/LAN])=True) AND ((IsNull([Service Request].[Act Hrs - PC/LAN Mand]))<>False) AND ((IsNull([Service Request].[Act Hrs - PC/LAN Discret]))<>False)) OR ((([Service Request].[Proj Category])<>"Annual Production Support") AND (([Service Request].[FHB Status])="Approved" Or ([Service Request].[FHB Status])="Implemented" Or ([Service Request].[FHB Status])="On-Hold") AND (([Service Request].[Revised Commitment Date]) Is Not Null) AND (([Service Request].[Copy - PC/LAN])=True) AND ((IsNull([Service Request].[Act Hrs - PC/LAN Mand]))<>False) AND ((IsNull([Service Request].[Act Hrs - PC/LAN Discret]))<>False)) OR ((([Service Request].[Proj Category])<>"Annual Production Support") AND (([Service Request].[FHB Status])="Completed") AND (([Service Request].[Orig Commitment Date]) Is Not Null) AND (([Service Request].[Copy - PC/LAN])=True) AND ((IsNull([Service Request].[Act Hrs - PC/LAN Mand]))<>False) AND ((IsNull([Service Request].[Act Hrs - PC/LAN Discret]))<>False) AND (([Service Request].[Actual Completion Date])>=#7/1/2010#)) OR ((([Service Request].[Proj Category])<>"Annual Production Support") AND (([Service Request].[FHB Status])="Completed") AND (([Service Request].[Revised Commitment Date]) Is Not Null) AND (([Service Request].[Copy - PC/LAN])=True) AND ((IsNull([Service Request].[Act Hrs - PC/LAN Mand]))<>False) AND ((IsNull([Service Request].[Act Hrs - PC/LAN Discret]))<>False) AND (([Service Request].[Actual Completion Date])>=#7/1/2010#));

    What's going on? For example, you can see that the statement '(([Service Request].[Actual Completion Date])>=#7/1/2010#))' is repeated at the end. Is this one of the many limitations in Access? Where a large query gets misinterpreted? Is there a workaround? Please advise, thanks!

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    That's the way Access interpret the query in design view. It may run slower but the result won't be different as yours.

    For example,
    (a or b) and (c or d)
    will be changed to
    (a and c) or (a and d) or (b and c) or (b and d)

  3. #3
    dso808 is offline Novice
    Windows XP Access 2003
    Join Date
    May 2010
    Posts
    6
    Thanks for the quick reply Weekend! You're right. After breaking everything down in Notepad, I think the Access-altered version of my query should be OK. It's perhaps the data in the record which may explain why it's not showing up in my report. Thanks again and have a great weekend :-)

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

Similar Threads

  1. Replies: 1
    Last Post: 06-30-2010, 12:47 PM
  2. Query Design View Takes a Long Time to Open
    By jackthedog in forum Queries
    Replies: 0
    Last Post: 12-22-2009, 03:27 PM
  3. Replies: 9
    Last Post: 10-09-2009, 08:15 AM
  4. Access query
    By timboellis in forum Queries
    Replies: 1
    Last Post: 09-19-2009, 08:39 AM
  5. Sql server query to MS access query
    By blazixinfo@yahoo.com in forum Queries
    Replies: 0
    Last Post: 07-07-2009, 08:12 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